# Cypress 12 with Ely Lucas

An episode of [.NET Rocks!](https://invisiblenetwork.ai/podcast/130068596), 27 Apr 2023, 51 min.

Audio: https://dts.podtrac.com/redirect.mp3/api.spreaker.com/download/episode/53660593/dotnetrocks_1843_cypress_12.mp3

Web Testing Evolved! Carl and Richard talk to Ely Lucas about the latest version of the Cypress Testing Framework. Ely talks about three significant versions shipping in 2022 - starting with version 10, a complete UI overhaul. Following the semantic versioning standards, versions 11 and 12 had some breaking changes, primarily around component testing and other great new features. Today Cypress is effective at end-to-end testing, component testing, and with an open source plugin, API testing. The product is free and open-source, with a paid version offering enterprise-class cloud services for scaling testing up. Check it out!

## Transcript

[0:01] How'd you like to listen to dot net rocks with no ads? Easy?
[0:05] Become a patron For just five dollars a month you get access to a private
[0:10] RSS feed where all the shows have no ads. Twenty dollars a month will
[0:14] get you that and a special dot net Rocks patron mug. Sign up now
[0:18] at Patreon dot dot net rocks dot com. Hey Carlin Richard Here. As
[0:24] you may have heard, NDC is back offering their incredible in person conferences around
[0:29] the world, and we'd like to tell you about them. NDC Oslow will
[0:33] be me twenty first through the twenty fifth. Go to NDC Oslo dot com
[0:37] to register. NDC Copenhagen is happening August twenty seventh through the thirty first.
[0:42] The early bird discount for NDC Copenhagen ends June second. Go to NDC Copenhagen
[0:49] dot com for more information. NDC Porto is happening October sixteenth through the twentieth.
[0:54] The early bird discount for dc Porto ends July twenty first. Go to
[0:59] EDDC Porto dot calm to register and check out the full lineup of conferences at
[1:03] NDC Conferences dot com. Hey, guess what it's Donn Rocks. Wow,
[1:22] I'm Carl Franklin and I'm Richard Campbell. What do you know? Just happened
[1:26] again? It's so strange. I know eighteen hundred and forty three times that
[1:32] we've done this stupid show. I think it's that stupid. But you know,
[1:38] it's not that I haven't done that many. I'm a slacker. I'm
[1:41] the new guy. We were just talking about podcasts and the pod in podcast
[1:48] I always have to explain to you know, and well, that's because there
[1:51] are no iPods anymore, right, Like that product's gone. That's right,
[1:55] that's what it stood for. It was iPods where the where the device of
[1:59] the day. Yeah, it's just like you know, Microsoft had Channel nine,
[2:01] which was based on United Airlines Channel nine, where if you're flying United
[2:06] you could switch a Channel nine you could listen to. The United doesn't do
[2:08] that anymore. So like nobody knows what Channel nine means. It's gone.
[2:14] It's just funny. People people would say, hey, have you heard about
[2:16] podcasts, and I say no, no, no idea. Really it's just
[2:25] a little weird. All right, let's roll the crazy music for better no
[2:29] framework awesome? All right, man, what do you go, all right,
[2:38] well, I'm talking about the dot Net Show, which is a video
[2:43] show that I do. It's presented by Devi Express, right, and it's
[2:47] all about Maui right now. And I don't mean their tools, just general
[2:52] Maui stuff. And I started building in zamorin Forms. I started building a
[2:57] dot net rocks mobile podcasts in a podcast a client app right for iOS and
[3:04] Android. And then when Maui came out, I started rebuilding it because there
[3:07] was no converting it. That was just silly. Different approach, different approach,
[3:12] different projects, structure and everything. So we just started over and we
[3:15] got to four episodes on that and then the app doesn't really look all that
[3:21] great right now, but it's functional, right, So I figured this is
[3:23] the time to start the process of publishing to the app store. What is
[3:29] involved, you know, of moving parts, lots of moving parts, And
[3:34] I realized that I'll be an update hell forever. Yeah, but you got
[3:38] to start somewhere. So this, you know, this is episode eighteen forty
[3:42] three. So if you get eighteen forty three popped up me, that'll bring
[3:46] you to a YouTube video where I go and register yes, brand new accounts
[3:53] in Google Play you know, a Google developer and in Apple developer through the
[4:00] two app stores. Yeah, the two app stores. So I'm starting from
[4:02] scratch, and both of them require a waiting period where you have to get
[4:08] approved, and so the following week then we'll pick up where we left off.
[4:12] We're just going to go through the entire process, warts and all.
[4:15] Yeah, get right through it until you see your thing appear in the store
[4:17] and exactly and then start looking at updating it and how much fun that is.
[4:21] Absolutely I can't wait for that. That's going to be the show,
[4:25] right, Okay, you've published it well? And also like, what if
[4:28] they turn you down? Right? Like I almost tempted to put in something
[4:31] inappropriate in it just to see if they will turn it down. Oh,
[4:33] Richard, don't get me any ideas, because you know it's all an experiment.
[4:40] In the test, man, you might as well try test the limits
[4:42] of the system. Well, I am really interested in what happens when you
[4:45] want to update, right, because I know that there's pain around that.
[4:47] I've heard the time is the whole thing, especially when the Apple updates their
[4:51] OS and it breaks your app and all you need to do is recompile and
[4:55] redest why but that still takes time. Yeah, we had that problem with
[4:59] the last app that we had, which, by the way, it is
[5:00] no longer out there, so it's gone yeah yeah for various reasons. But
[5:04] this is going to be our dot net rocks app, and I'm going to
[5:09] document the whole process of publishing it and getting it in the app store.
[5:13] Awesome, That's what I'm doing. Okay, so part one, No it,
[5:15] learned it, love it. Who's talking to us today? Richard grabbed
[5:17] a comment of the show sixteen fifty nine, the one we did with one
[5:20] Jennifer Wooddell. I remember Jell. Yeah, we were talking about modernizing Angular
[5:25] apps and it certainly dug into Cypress and a bunch of other testing frameworks so
[5:28] forth. But that was back in twenty nineteen, so that's the before time.
[5:31] As we say in New England, she's Wick, it's Matt. Yes,
[5:35] it's true. She Wick Wick, It's Matt. And the comment comes
[5:41] from Red Dorian, who says, I have worked with Cyprus in Anger for
[5:44] more than a year, and this is now three years ago or four years
[5:46] ago, and I feel safe enough to comment on its usage performance. I
[5:49] wouldn't consider it replacement for unit tests. It has greater functionality in the end
[5:55] to end testing or automating user testing. As with all testing, there was
[5:58] a balancing act of how much testing you do, and the more testing you
[6:01] do with Cyprus, the longer your builds can take. And I'm talking adding
[6:04] anywhere between five and twenty minutes to a build. As you gain more experience
[6:09] with it, you learn where and what to test. But it's definitely an
[6:11] a compliment to unit testing with Karma, but not necessarily an alternative. Again
[6:15] four years ago, so the tools of evolved. The infancy of a technology
[6:19] is a factor that definitely needs to be taking a new account before jumping on
[6:21] the latest and greatest. Such is the cost of living on the bleeding edge.
[6:26] The cost of living on the bleeding edge is bleeding. Amen, did
[6:31] you just do that yourself? You had that in or is that actually okay?
[6:36] Little commentary, little editorialization there, But well, Red, we're about
[6:44] to introduce you to the newer versions of Cyprus because things have evolved, and
[6:47] it's great that you were on board back in the twenty nineteen twenty twenty because
[6:54] it's always good to have a view back of the player. Things started and
[6:56] I appreciate your thinking around how you mix stuff up, and that the price
[7:00] of testing. You know that that additional time is worth it because it makes
[7:03] feel more reliable software. Absolutely. So a copy of music code By is
[7:06] on its way to you. And if you'd like a copy of music codey,
[7:09] write a comment on the website at dot net rocks dot com or on
[7:13] the facebooks. We publish every show there, and if you comment there and
[7:15] everybody little show, we'll send you copy of music cod by. And by
[7:17] the way, music to Codeby has another brand, music to flow by,
[7:21] that's not just for developers, And I will also build an app for that
[7:27] and put that in the app store once I get the dot net rocks thing
[7:30] in there. That's gonna be fun. And you know, you can definitely
[7:34] follow us on Twitter if you want to. But I think the cooler place
[7:39] to hang out these days is masteredon Sir Richard and I are both there.
[7:42] I'm at Carl Franklin at tech Hub dot social and I'm Richcampbell at Masterdon dot
[7:46] social. So send us a tute and join join the tutors. All the
[7:51] tutes, yeah, all the tutes. And you know, I think I've
[7:55] resigned myself to not making up a joke. Right there, I'm done.
[8:00] That joke is done. Send us a tute. That's about it, all
[8:05] right, So let us introduce Eli here. Eli Lucas is the head of
[8:09] developer Ecosystem at Cyprus and has been doing software development for over twenty five years.
[8:15] After spending the first fifteen years doing dot net development, Eli moved more
[8:20] to the front end world and has been drinking the type script kool aid ever
[8:22] since. Lately, he's been focused on sharing techniques on producing better quality software,
[8:30] with testing at the heart of it. He lives in Denver with his
[8:33] wife and four kids, and when not developing, can be found taking his
[8:37] chaos on tour around the Colorado Mountains and probably breathing more heavily than you want
[8:43] him to. Because I've been to Denver. I kudn't even breathe now.
[8:48] Actually it was in Breckinridge that I really lost my breath. That's above Denver
[8:54] and it yes it is anyway. Welcome Eli, thanks guys, pleasure to
[9:00] be here. It's one way to keep four kids settled down, deprived them
[9:03] of oxygen and make them run around the coolest combination. Yeah, we actually
[9:07] we actually do that every year. We take them up. We go up
[9:09] for a week during the summer to Breckon Ridge every year. So it's good
[9:13] there you go. Breckon Ridge was so cool. They have the in the
[9:16] grocery stores. They have containers of oxygen that you can buy for a couple
[9:20] of bucks. And you know, anytime you feel like you just put that
[9:24] on and you feel better. It's crazy nice. Yeah, pressurized oxygen in
[9:28] the grocery store. Three thousand meters up, that's legit. Oh yeah,
[9:35] it's fourteen thousand feet something like ten thousand. Yeah ten. Denver's nine thousands.
[9:41] So I thought Breckon Ridge is abound. Denver was five. Yeah,
[9:46] okay, mile High City. That's why it's to Mile High City. Yeah,
[9:48] all right, okay, correct me on my math. That's right.
[9:50] It's been a while. As I said, I was oxygen deprived when I
[9:54] was there. You make too many memories that stuck around. Um Eli,
[9:58] tell us about Cypress and what it is. I mean, we've talked about
[10:03] it on the show before, but I'd like you to explain it for everybody
[10:05] who may not have heard about it. Yeah. Absolutely, So for those
[10:09] of you who may not know what Cypress is we are a free, open
[10:16] source utility that you can use to test anything that runs inside of the browser.
[10:22] And so our bread and butter has been pretty much in testing. That's
[10:26] what people primarily know us. For a few years back. We came onto
[10:31] the scene as being a quick, easy way to get into intesting up and
[10:35] learning inside your apps. Okay, and I guess it's in the category of
[10:41] testing tools. But as it works, as it works inside the browser,
[10:46] does it integrate with IDEs? How does that work? So the primary way
[10:52] that people work with Cypress is through our tool that you download and install.
[10:58] And to kind of go back into like how you get started with Cyprus is
[11:03] that it's an MPM installation that you install and to you typically your front end
[11:07] portion of your project, and then once you fire it up, it opens
[11:13] up a desktop application that you can use to start running your tests and whatnot.
[11:18] And so there might be like plugins and whatnot out there that you can
[11:24] use inside of your ide, but our primary interface is through this desktop application
[11:28] that you use. All right, very cool, and so do you have
[11:33] any answer to the message that Richard read there? It was granted four years
[11:39] ago, but I mean I take it things have changed a little bit.
[11:43] Yeah four years ago. Man, so much has changed since then. And
[11:48] if I recall, like the context around the message was around unit testing,
[11:54] maybe something about comparing testing type tools. Yeah, he was just saying that
[11:58] he's doing unit testing elsewhere, Yeah, right, not doing testing with Cyprus,
[12:03] which I wouldn't disagree with. Yeah. Yeah, So that's one of
[12:05] the things, Like with Cypress you can really test anything that runs inside of
[12:09] the browser, and so if you're testing to your front end code, your
[12:13] JavaScript that runs inside of the browser, you can definitely do so with Cyprus.
[12:18] It's not necessarily what we come out and advertise that's possible, but you
[12:24] can do it. What you would typically use for something like that is like
[12:28] just Right or Mocha directly to do those types of things, and the test
[12:35] runners to do unitype tests are probably better suited, like Jess is probably better
[12:41] suited for unit testing than cypresses. Right. Well, I guess suppose an
[12:45] advantage as you get if you wanted to do unit testing with Cyprus is that
[12:48] now you're all underneath one tool, with one set of APIs, one one
[12:52] learning curve to get everything done. As they say in the enterprise world,
[12:58] one throat to choke. Is that inappropriate? I don't know. I don't
[13:05] think so. It's a term, it's a term we use. It's pretty
[13:07] accurate. Yeah, all right, But yeah, if we go back to
[13:11] the timeframe that Red's talking about, that late twenty nineteen early twenty twenty,
[13:15] you really are talking about even before V one of Cyprus or maybe or maybe
[13:20] just V one V two. Yeah, it was, it was towards the
[13:24] earlier days. I'm not just sure what version would have been out because we
[13:26] come out with versions fairly rapidly. Yeah, it's yeah, impressive. So
[13:31] you guys had a major version number three version version numbers last year, ten
[13:35] eleven and twelve, Like, right, are you changing that much? Um?
[13:39] It's mostly well, so we follow semantic virgion Ingum, so when we
[13:45] come up with something that needs to be released that's going to require people to
[13:48] either update their codes or our epis are changing, you know, basically we're
[13:52] releasing. A breaking change is when we determine when we have to do a
[13:56] major version versus some type of shipping schedule. We do know towards the end
[14:01] of last year, because I think we released V eleven in like December and
[14:05] then V twelve like a month or two later in January February. Wow,
[14:11] and that was pretty quick even for us, but it's what we needed to
[14:15] do to kind of like hit some of these feature releases that we wanted to
[14:20] do. But the big one was V ten ok, and that was the
[14:24] one where we had a major UI refreshed because pretty much the UI hasn't changed
[14:30] at all since the Cyprus was originally released, and so the UI of the
[14:35] application got a total rehaul. But along with that, we released a new
[14:39] type of testing that you do with Cyprus called component testing. Okay, so
[14:45] what do you mean when you say component testing? Yeah, so specifically we're
[14:50] talking about the front end framework ceter, component based, so your Angular React
[14:56] view, any of these ones that kind of promote a component of an architecture
[15:00] where you break down the UI of your application and to small components that are
[15:05] usable across the app and so being able to test those on their own,
[15:09] not necessarily depending on a given page exactly. Yeah. So you're taking those
[15:13] components, you're mounting them in isolation from them the rest of the app,
[15:16] and then that way you can write tests that are just specifically for that widget
[15:20] versus like normally what you would have to do if you want to write test
[15:24] to it somehow throw it into the context of another page where it's going to
[15:26] be used. I we've built test pages with all of the components on it
[15:33] and then written the tests around that test page. It creates its own kind
[15:35] of hell. Yeah, yeah, and so this component testing is to get
[15:39] you out of that hell and to bring you to the light, all right,
[15:43] Yeah, being able to test the street. Like when I think componentization
[15:46] of controls, I think React especially. It's good at them like that seems
[15:50] to be there one of their claims to fame. It is very much that
[15:54] component mindset of style, function, all of that is all sort of bundled
[15:58] together. Yeah. On the JavaScript side, most of the um all the
[16:03] modern JavaScript frameworks subscribe to some type of component based architecture, right, and
[16:08] so we have official support for Angular, View, React and spelt okay,
[16:15] and then we also have the ability for the community to make their own mounting
[16:19] libraries because it is an open source project. Yep, it is an open
[16:22] source project, and we have a pretty vibrant community and ecosystem of people developing
[16:27] plugins for Cyprus, right, and so we are um a couple of minor
[16:33] releases back, we exposed an API that if you're a community like so,
[16:38] for instance, Quick is a newer front end framework that's coming out quic qu
[16:45] i k i k because games are hard, yeah, and did Neslee give
[16:51] them any problems? Isn't that that's chocolate drink? Yeah, let me let
[16:56] me double check that suspelling? But q q w i k qwik Yeah,
[17:02] because spelling things is hard, it is. Yeah, yeah, and searching
[17:07] for things like that is even harder. Oh yeah, no kidding. Try
[17:11] having a podcast with a period and beginning with the period is the first character,
[17:15] Like, what could go wrong? I'm I'm and I'm adding these all
[17:18] of the show notes, so I need I do want to find them all
[17:21] just so that folks can can look them up easily on the show. Yeah,
[17:25] but yeah, it's good to have Quick in there. I haven't looked
[17:27] it. Quick. It's another one. Yeah. So a Quick is being
[17:32] headed up by somebody who was one of the founders of Angular Misco. Yeah
[17:37] Misco. He's from the Angler team is working on Quick along with some of
[17:42] my old colleagues. I used to work out a coming called Ionic and some
[17:45] of my old college Ionic are also working on it. Yeah, all right,
[17:48] because there was the Ionic framework back in the day too, not that
[17:52] it's gone away, No no Ionic store around. Yeah, um, but
[17:56] yeah, that's that's an example of another like you know, really new.
[18:00] I think they just released their first RC a couple of weeks ago, but
[18:03] they're kind of disrupting the front end industry with yet another JavaScript framework, but
[18:10] making massive strides and performance and developer experience and all that fun stuff. But
[18:15] now the folks at Cyprus no longer have to debate do we add quick support.
[18:19] The API means if Quick ones to be supported in Cyprus, they can
[18:22] do it themselves exactly. Yeah, And we were actually working with the Quick
[18:26] team and their developer advocates and whatnot to get the library written and we're promoting
[18:32] it together. But yeah, because when we work on our own mounting library
[18:38] that is an efficient officially a part of the product. There's a lot to
[18:41] go along with that. We have all the documentation, all of our examples
[18:45] like show it also. Yeah, but that's what it takes for folks to
[18:49] be successful with it, right. It's like you guys who got a template
[18:52] where here's the things you need to do so someone can use Cyper successfully with
[18:56] your web framework exactly. I like it, you know, it's it speaks
[19:00] to our responsible approach to allowing people to be successful with their tools. Yeah,
[19:07] definitely, because goodness knows, we don't have enough jab script frameworks.
[19:12] Did I say that loud? I'm sorry? I apologize, all right.
[19:15] So the component testing is obviously a big piece and being able to do that
[19:19] discreetly other particular kinds of testing that I mean, you guys are famous for
[19:23] end to end yep. So, like I said, d end is primarily
[19:26] what we're known for. We're making a splash in the component testing scene.
[19:30] M Something else that's really interesting that is starting to gain a lot of interest
[19:34] that you can do with Cyprus is api testing, okay, And so we've
[19:38] had the ability because we have a method that you can use to make HTTP
[19:44] requests to a back end server inside of our API for the longest time,
[19:48] and people have been using that to write integration style tests to a backend API.
[19:56] So you make the requests and then you can check the content checked the
[20:00] status codes and the headers and all that fun stuff to make sure that you
[20:03] expect them to be what they are. But we had a community member make
[20:07] a new plug in that's called the Cypress plug in API that actually gives you
[20:11] a nice interface that shows you the contents of the body, the headers,
[20:17] all this other fun stuff. And so if you ever used something like Postman,
[20:21] it's kind of taken Postman but putting it inside of the Cypress Testing application.
[20:26] And so you use it, not only are you getting the benefits of
[20:30] like visualizing your API requests, but at the same time you're getting a set
[20:33] of tests that go along with it as well. Nice so sort of sets
[20:37] the standard for all the things you should be testing on an API. Yeah,
[20:41] and did that get introduce in ten as well? So that is a
[20:45] community plug in, right, I think it requires v ten because it has
[20:49] its own UI that comes along with it and whatnot. And so yeah,
[20:55] that makes sense, okay, And I found Phillip's repository for it, so
[21:00] yeah, just include that in the show notes too. The people can go
[21:02] and grab it. Yeah, I Philips one of our great ambassadors. Yeah,
[21:04] it's awesome and it just so it seems to me like ten because you
[21:11] created tooling around letting the community be more effective with you is why it's such
[21:15] a big version. So what happened in eleven and twelve? Okay, So
[21:19] the big thing was with Cyprus eleven. So Cyprus ten released the beta version
[21:25] of Component Testing right, and Cyprus eleven brought Component Testing out of beta into
[21:30] general availability, and with that there were some API changes and stuff that we
[21:34] wanted to make to get it out. Cyprus twelve was a bit bigger of
[21:41] our release, and that I saw a couple of features that our community have
[21:47] been asking for for a real long time. And so one of them was
[21:52] the way that Cyprus is architected is that when you write your tests, instead
[21:57] of like driving like a web browser via like a protocoler or anything like that,
[22:03] we actually take your test code and inject it inside of your application.
[22:07] Okay, and so the test code has direct access to all the HTML and
[22:11] the buttons and the elements and the dom right that would but because of the
[22:15] way that we're running, we had security issues when you had to go to
[22:21] another domain to do something. Yeah. Yeah, that makes sense because it
[22:23] looks like code injection, right, yep. Yeah. The only difference between
[22:27] you and a regular man in the middle of the track is you're the good
[22:30] guys. Otherwise it's the same thing. So we figured out a way that
[22:33] we could actually get around that, and that's what we call side dot origin
[22:37] is the new API and with side dot origin inside of your test when you're
[22:42] up out ready to transfer to new domain. So a common use case for
[22:47] this is third party authentication, right, and so you click a log in
[22:51] button you're going to go over to like Google or an auth provider like off
[22:56] zero or Opta, and inside of your code you use site dot origin.
[22:59] You're like, hey, I'm about we're about ready to make an origin change
[23:03] to this new domain name. Everything that's inside of the side out origin block
[23:07] execute inside of that new domain name, and so they'll take that code,
[23:11] put it into the new one, and then when you come back to your
[23:14] website, you exit the site origin and you're able to do that. But
[23:18] this makes it possible because we had a limitation before that you couldn't go to
[23:22] a new domain and do anything. You had to like work away, work
[23:25] yourself around it programmatically. But now you can actually just use the website like
[23:29] a normal user would. Yeah, that was my next question is how much
[23:33] JavaScript does one have to know to effectively use Cyprus. Yeah, and so
[23:37] writing your tests in Cyprus is either written with JavaScript or type script. But
[23:42] we've written the API in a way that it's more like I like to think
[23:45] of it as like a DSL, the domain specific language into testing. And
[23:51] so we have an API that is very fluent and chains off of each other,
[23:56] and so when you write the test, they kind of read a lot
[23:59] like English. And so the first thing that you're going to want to do
[24:02] is like select something inside of your site, and so you'll use a selector
[24:07] and a method to do so. And the primary way do you do that
[24:11] is with the get method, and so you say side dot get and then
[24:15] you pass in some type of selector. And the selectors are a lot like
[24:18] j C Ray selectors, and so you can select via class name, via
[24:22] ide, via elements, attributes and whatnot. We have best practice guides on
[24:26] how to do this in a good way. But then you select your element
[24:30] and then you take some type of action on it. And so like let's
[24:33] say you select a button and now you want to do something. You want
[24:37] to click it, and so you call the click method, and then after
[24:41] that you want to run an assertion, and so you have the assertion that
[24:45] is should and so you say dot should and then you say like should have
[24:48] been clicked or you know, text should equal whatever result you're expecting to be.
[24:55] But when you're looking at the code itself, it's very English like.
[25:00] And because of that, we have a lot of kind of QA teams that
[25:04] aren't necessarily developers, but they just know enough to go in there and be
[25:08] able to write test with Cyprus. And if your app becomes really big and
[25:15] you're constantly adding functions and functionality, that QA team is going to have to
[25:21] grow too, isn't it um? Yeah, And so we got we do
[25:25] have certain ways to be able to organize your your code, and we have
[25:30] a mechanism that we call custom commands, and this is where you can create
[25:34] your own command method that chains off of the side object and so you can
[25:38] actually use it as part of its fluence and tax. But one example might
[25:44] be like you need to log into your app. That's a common thing that
[25:48] you have to do, so you don't want to put that code in every
[25:49] single test that you need to do that in, and so you can create
[25:52] a custom log in command that will do your login for you, and then
[25:56] you can say side out log in, and then you can say dot get
[26:02] the avatar that shows that you locked in. Okay, so wait a bypass
[26:06] that now. And I've played with Cypress, I think we use the recorder
[26:08] primarily. Is that still a thing? Yep? Yeah. So it's called
[26:12] Cypress Studio, and it's an experimental feature right now, has been since it
[26:18] came out. So there's a flag that you have to turn on and side
[26:22] of the configuration. But with that you can use it to record your actions
[26:27] against a website. And so you can go through do a bunch of clicking,
[26:32] and then at the very end you can write click on something and add
[26:34] an assertion. You could be like this tech should equal what I expected to
[26:37] be and I will overrecord that, right, And it's just writing a DSL
[26:41] under the hood for you. Yep. Yeah. It actually takes a Cypress
[26:45] code, puts it inside of a JavaScript file along with all your other tests,
[26:49] and then from there that can get you like, you know, eighty
[26:52] percent of the way that are to a complete test. And from there you
[26:55] can just go and modify the JavaScript directly. Right now, the tool doesn't
[27:00] go back and modify an existing test. It's previously recorded, right so not
[27:04] re entrant. It just generates your initial impact paths and then you tweak it
[27:10] correct. Yeah, that's fair. Yeah, that was one of that was
[27:11] one of those things. And so in Cyprus ten, since we redid the
[27:15] entire UI, one of the shortcuts that we took was actually getting rid of
[27:18] to Cyprus Studio, right, And we got a ton of feedback from that.
[27:23] I think a lot of people were relying on the on the recorder man
[27:27] like that's yeah, yeah, what'd you replace it with? One of the
[27:30] subsequent releases, we did put that back in there, so there we go,
[27:33] Okay, well, what were you going to replace it with something?
[27:37] What was the idea? So it's a it's a it's always been an experimental
[27:41] feature since it's first came out, and that's because, like, while it
[27:45] is useful, we do know that it has quite a bit of limitations as
[27:48] far as like usually you do have to go in and kind of modify the
[27:52] code to get it to do exactly what you wanted to do, and you
[27:53] can't, like I said, you can't change previous tests with it. So
[27:57] expectations were too maybe yeah, yeah, And so it's it's one thing that
[28:03] we find is that it's a great learning tool because you can use it and
[28:06] go through and do things and then see the code that is writing for you
[28:08] and be like, Okay, that's that's how you do this, and right,
[28:11] this is how you Yeah, provided to the code you're generating is the
[28:15] best practice code. Yeah, then you're going to teach us best practice code
[28:18] just by starting to generator. But I love this hole getting over the blank
[28:23] screen syndrome. So Rana write a test. Here's the blank screen. Have
[28:27] a good time being able to use the recorder. Sort of lay down the
[28:32] initial template. This is the page, here are the fields, here's the
[28:36] assertion. Go. Now you go in and say, all right, well,
[28:40] I want to tinker with the log in this way, and I want
[28:41] to deal with this thing that way, and like there's a bunch of tweaking
[28:45] you do. But at least you're starting with a template. And guys,
[28:48] hold that thought for this very important pause, for these very important messages.
[28:52] We'll be right back. Hey, guess what, it's Dot at Rocks.
[29:00] I'm Carl Franklin. That's my friend Richard Campbell. Hey, and we're talking
[29:03] to Eli here about Cyprus. And my next question, if you haven't guessed,
[29:10] is any plans to support Blazer oh man, so web assembly all up,
[29:17] Like, how do you support testing and web assembly? Yeah, or
[29:18] even Blazer components server components. Yeah. So it's a multi multi faceted questions.
[29:23] So on the one end, with end in testing, Cyprus can testing
[29:26] anything that runs inside of the browser. Sure, And so if you fire
[29:30] up a development server and you hit a Blazer web app, and even if
[29:34] it's running web assembly, it's going to run inside of the browser and you'll
[29:38] be able to do it that way. The more interesting question is doing component
[29:44] testing web Blazer, because typically what we will do is we will load up
[29:49] the component inside along with our test code and mount to component directly, and
[29:56] then you can modify any of the properties or inputs that are going into the
[30:00] component and mess around with its API directly, which could be a challenge a
[30:04] Blazer like we could probably figure it out. We haven't heard a whole a
[30:10] lot of interest with that yet, but I have definitely thought about it,
[30:15] um and the and the more interesting challenge might be if it's just a flat
[30:19] out server based Blazer app, right, or everything's rendered Yeah, an server,
[30:26] Yeah, exactly. That That's that's an interesting dilemma, isn't it,
[30:30] Because there are some testing frameworks for Blazer, but they're like b unit is
[30:33] a unit testing framework Blaze. Yeah, end to end tasting of a Blazer
[30:38] app. That's an interesting problem needs to be done. Just a question of
[30:42] what you know, what can you hook to snapshot testing? You know Simon
[30:47] crops tools good for that, Verify right, just comparing code. But and
[30:51] and Richard's observation about web assembly, does that throw a monkey wrench in your
[30:56] plans? I No, I don't think so, because we we use real
[31:02] browsers to run our tests with, and so there are browsers that are installed
[31:06] locally on on the system that you're using to test it. One of the
[31:10] one of the very first questions you get as you're firing upside press is like,
[31:11] hey, what browser do you want to test in? Right? And
[31:15] so we have support for all the Chromian based browsers, so Chrome and Chrome
[31:21] and Edge, mainly support for Firefox, and then recently here recently we also
[31:26] have experimental support for safari um, so that that's another flag that you have
[31:30] to turn on to be able to use it. That was another feature that
[31:33] Redness knows it needs to be testing. It's waiting for that comment. Yeah,
[31:37] so as he said, Safari Richard's brow furrow did and he was like,
[31:41] oh, dang it. But anyway, Yeah, so but web assembly
[31:47] is interesting because you know, the code's running in that little sandbox, and
[31:51] the only JavaScript that you can look at is what's outside the sandbox, and
[31:57] uh, you know who knows what it's written in. Yeah, and for
[32:01] that it should be probably into intesting is going to be the best of it,
[32:05] because then the Cypress tool is just going to interact with the HTMLA that
[32:08] gets outputted from the Blazer app however, directly, which is easier in some
[32:14] senses. Yeah, so testing the Cypress is very black box like. Cypress
[32:19] really should not know a whole lot about the internals that's going on. It's
[32:22] a proper point of abstraction. I don't want to know it's all implementation details.
[32:27] You should be testing your application just like your user or would actually use
[32:30] it. Right order. That starts to break down a little bit as with
[32:32] component testing, because with component testing, you need to know a little bit
[32:37] about how your application works. You need to know like what framework it's written
[32:40] in, how to pass in properties to the components and whatnot. But really,
[32:44] as soon as you haven't mounted. It's just like an into intest.
[32:46] It gets rendered inside of the browser and then you can start. It's the
[32:51] plumbing of forcing a rendering so that you can test it. It's crossing into
[32:55] the line, poking underneath the cupboards a little bit to say, yeah,
[33:00] I need to I need you to make one of these for me so I
[33:01] can beat on it. That's a bit more specific. I mean you almost
[33:06] wonder if web assembly the standard is going to evolve to provide for capabilities,
[33:12] for more testability and so forth, and in that level, I mean,
[33:15] it's not there yet, but I can see that being the path because I
[33:19] think WA has particular application in like internal apps and things like that where they
[33:25] want they want to developers to work in the environment they know, and they
[33:30] want that code to be well tested. So I imagine it's going it's going
[33:34] to continue evolve. That's a lot of moving parts. I mean, how
[33:36] much how much impact do you have when a browser does an update, Like
[33:39] how does that affect Cyprus? Um? Not a whole lot, especially with
[33:45] how frequently they all come out with newer versions nowadays. Um, it's pretty
[33:50] rare. That will be like, oh, now browser came out and broke
[33:53] everybody's tests that we're using that browser. That's a bad day that that is
[34:00] something on your desktop. It's a little bit harder to control your browser versions
[34:04] or whatnot. But if you're running your tests in like cic D, yeah,
[34:07] we actually Cypress actually provides Docker images that you can use along with your
[34:13] CSD that has browsers included with it, and so if you needed to set
[34:16] like a browser or a certain version, you can just use that darker image
[34:21] for it and nice. So one of the gotchas of modern web programming,
[34:27] especially with spas, right with single page applications, is that elements just come
[34:31] and go. You know they're there, and then they're not there, and
[34:36] when you create them, they're not there. You have to wait before they
[34:38] render, before they show up. So does Cypress have any issues with spas
[34:45] in particular? You know, what if the IDs are dynamically generated? God
[34:51] forbid? I mean, I don't know who would do that, but you
[34:53] know I can think of evil ways to to to throw a monkey wrench in
[34:57] there. Um, do we you have to add specific attributes to things in
[35:02] order to find elements and what happens if they're not there? I mean how
[35:06] do you handle those things? Yep, okay, yeah, So I'll tackle
[35:08] that in two parts. I would say the first part, like how how
[35:12] to handle things when they're not there? Might be like one of the virginal
[35:15] reasons why Cyprus was invented. I like that because because for Cyprus UM and
[35:24] the and the testing solutions that were out there, this was like one of
[35:29] the very big problems. You try to select something wasn't there, and then
[35:31] all of a sudden your tests it feel and so you'd have to put in
[35:35] these weights into your code. Ye be like, hey, I did the
[35:37] API request, Let's wait a second for everything to show up. Oh it's
[35:40] not there yet. Let's wait another second. Set time out ten milliseconds,
[35:45] call myself, yeah, like you millisecond optimism, right, Like you know,
[35:51] maybe it might be a minute. You got to go and actually render
[35:52] the page. And so this may this made the reading or writing and reading
[35:57] the code more complex than what it needs to be. And then also just
[36:00] introduce this level of flakiness to the test, like sometimes it's going to work,
[36:05] sometimes it's not going to work. Cyprus with its API has built in
[36:10] waiting and retriability, right, nice, And what I mean by that is,
[36:15] if you say hey, using the CYPRESKIP method, if you say hey,
[36:17] go get me a button with like maybe some particular text like loggin.
[36:23] If that doesn't exist yet, Cyprus is going to wait up to four seconds
[36:30] for that to actually pass. That's enough time, and so that gives yeah,
[36:34] that's usually enough. And that's completely configurable too. You can do it
[36:37] at a global level, you can do it at a test level, but
[36:39] one would argue if it's more than four seconds, it's not going to happen.
[36:43] The customer left anyway, nobody cares about your rendering. But along with
[36:50] that, we also have built in retriability, and so let's let's say we
[36:52] have a scenario where we're looking and at a list of users and we go
[36:57] to delete one of the users. So we delete the user, we hit
[37:00] the delete button, and now we're waiting for the road to disappear. And
[37:04] so we're going to write a test that says, hey, get me this
[37:07] row and it should not exist anymore. Right, well, initially it might
[37:10] still exist, sure, but we're going to notice that, and we're going
[37:15] to wait and then retry the assertion again up to four seconds. And for
[37:22] some reason yeah, and for some reason, that dam element is still there
[37:28] after four seconds and we failed to test to be like, yeah, you
[37:30] said you're going to delete this record, but the team actually get deleted,
[37:34] right, But it did eventually, lead just took a ten seconds to know
[37:37] how to rerender it has gone. That's that's very very cool, and you
[37:42] need that kind of stuff because spas man, they're just a whole different beast
[37:45] than your standing a lot of latency in them. Yeah, and just like
[37:50] the dynamic nature of them things, they're there and then they're not there,
[37:52] and then they're there again. Yeah, and then their ideas changed. Okay.
[37:58] Yeah. In the second the second part was about IDs and how do
[38:01] you actually find your elements. So what we actually recommend is you don't use
[38:08] constructs like IDs or class names to find the elements if your application. I
[38:15] have two schools of thought. I have the official Cypress best Practices guide,
[38:19] and then I have what I think is best practices. Not give you the
[38:21] Cypress version first. Okay, the Cypress version is to use a special attribute
[38:25] data attribute like data dash test ID to go and find the particular elements that
[38:31] you're looking for. That's great. It doesn't exist for any other reason yet
[38:36] exactly right, hide away from the rest of the system. I like that.
[38:38] Yeah. And the problems with using something like ID is that a developer,
[38:44] sometimes a developer and a tester or two different people. Developer may not
[38:47] necessarily know this idea is being used for something. They might change it.
[38:51] And then also the test break. Then also you have class names have the
[38:55] exact same problem. But then a lot of the times with our JavaScript libraries,
[39:01] those class names are being dynamically generated and have like goods at the end
[39:05] of them stuff like that, So those aren't reliable to use either. And
[39:07] also we moved from Bootstrap you know, point zero to Strap seven and all
[39:15] the class names have changed. Yeah everything boom, yep. Yeah, so
[39:19] I get I love it. I mean you're basically saying this attribute is for
[39:22] this purpose only and that's it. We're not going to share any other attribute
[39:28] or construct with anyone else, right, makes sense? Yeah? And so
[39:32] in the React ecosystem, the most popular way to test React components until Cyprus
[39:38] takes over, is called React Testing Library. I don't know if you've caught
[39:45] that. Listeners thought a mid drink. I almost did a spittake until becoming
[39:52] revolution dot dot dot. Just let that one hang in there, all right.
[39:59] The Yeah, React testing library, they have a philosophy that the way
[40:05] that you select elements should be around the same way that a real user would
[40:10] find an element on the screen, and a real user could at the same
[40:14] time be something like a screen reader. And so because of that, instead
[40:20] of using something like a data dash attribute like I just said, you might
[40:22] use something like the role that the attribute, the ARIA role that the attribute
[40:29] plays, and so like button and so you could say like, hey,
[40:31] get by a roll button versus like get me a button element directly, because
[40:37] your button may not actually be a button element. It might be an anchor
[40:39] tag, or it might be a customed divtag that's made to look like an
[40:43] holement or something like that. Role. Yeah, but if but if you
[40:45] set up your ARIA attributes correctly, you would have given that divtag an aria
[40:51] dash roll button. And then there's an advantage that you get to writing your
[40:58] writing your test with this philosophy, and that is that you kind of like
[41:00] have built in accessibility as well, right sure, Um, So there is
[41:06] another library called Cypress Testing Library that takes the testing library methods and makes them
[41:13] available inside of the Cypress apium attation to the SI dot whatever fluent interface and
[41:22] that is what I like. Okay, that's the ELI test uh philosophy.
[41:30] Yeah, and who makes the cypers testing library? Um, it's an open
[41:35] source community. UM so it's actually a part. So the testing library is
[41:39] a larger organization that kind of exists over the smaller libraries. So like React
[41:47] Testing library, Cypress Testing library, or is an Angular testing library or view
[41:51] testing library, all these libraries that um subscribe to the API live under testing
[41:59] library. Yeah. Yeah. Can we test features that involve things outside the
[42:04] browser, Like what if we're doing some signal our stuff and going browser to
[42:07] browser and you know, what if we're doing something that accesses the local system
[42:14] that you know, download the file or something like that. Um ye,
[42:16] is there any way to do that? I mean anything that the browser does,
[42:20] Um, you should be able to do inside of Cyprus. So what
[42:23] about two browsers. What I'm saying, what if you've got some to two
[42:27] browsers at the same time is going to be more difficult just because we only
[42:30] load up inside of one browser. Okay, So but something that you can
[42:36] do to perhaps get around that is we have some network mocking and intercepting built
[42:43] in, and so it's kind of like a like a stubbing library, okay,
[42:49] where you can stub out network requests, and so if you're making a
[42:52] web soccer requests, you can stub that out and provide values for it instead
[42:59] of it actually talking to a second browser for real. Okay, But there's
[43:04] any way that I can you know, open one browser and then do something
[43:08] and then open another browser, get the result of that, and orchestrate both
[43:13] of those things under one test. I mean, there's probably a way.
[43:17] I think the challenge would be to be able to orchestrate that workflow and get
[43:22] it to like give you like reliable results, right, make it reliable.
[43:27] That's what I would be already about. That sounds like a challenge for a
[43:30] similar listener who wants to do a pull request. That's what I'm thinking.
[43:35] Make a contribution, Make a contribution, yeah, because you are taking contributions.
[43:38] Yeah, And speaking of that, where do we go to take contributions?
[43:43] Here? Where's the what's the website? Where's the GitHub repo or whatever?
[43:45] For the Cypress Yeah, for the Cypress open source or just Cyprus in
[43:52] general. Yeah, the Cypress open source Okay, So we're at GitHub,
[43:55] so gethub dot com, slash Cypress dash io couldn't be easier. And there
[44:00] you can find the main Cypress project and tons of example applications and the documentation.
[44:09] Okay, well pretty much all this stuff that we do is open source
[44:13] and including the docs. And so if you notice something like in our doc
[44:16] set roun like, you can go in and open up a pr and help
[44:20] fix up the docks as well, make submit it to the docs, prove
[44:23] great explanations. That's great. So what about large scale testing? So I
[44:28] built up a big test suite Now it takes hours to run. Is there
[44:31] tooling to allow me to spread this across multiple workloads and try and speed things
[44:36] up. So the Cyprus app itself, like I said, it is free.
[44:39] It's open source, it always will be free. You can take it
[44:43] and use it to your hearts extent. We do have our commercial service how
[44:46] we make money. It's called Cyprus Cloud and it's for larger projects that are
[44:52] growing, and it's to help you scale and give you analytics into your testing
[44:57] suite. Okay, and a few a few of the things that it as
[45:00] is what you're just saying, Richard, is you can use cypress cloud to
[45:04] scale out you're testing across multiple instances to get parallel into your tests. Yeah,
[45:09] it's strangely. We were always big on the being able to run the
[45:13] entire test back in fifteen minutes because give enough time to the developer to stretch,
[45:19] declare they are a god, and this god needs coffee, Go get
[45:22] coffee, and by the time they got back from coffee, the test results
[45:27] are in and they were not a god after all. But the point being,
[45:31] the code still in their head when they get the testing report back,
[45:37] rather than having to figure out like why did this fail? It's current enough.
[45:40] Like we at one point, I think our test week was running over
[45:44] a weekend, and so by the time you've got your test results it was
[45:46] Monday, and anybody could have written that code on Friday. You have no
[45:51] clue. So it's I really appreciate that the power of when we can rapidly
[45:57] do the tests and get it into the hands of the developer, that they
[46:00] can they while the coast on their head. They respond fast. Yeah.
[46:04] Yeah, that's the whole purpose of setis Cloud. It's about optimizing human time
[46:08] versus machine time, right, and so we do that sometimes by optimizing machine
[46:14] time, like spreading the workload over or we have a feature called smart Orchestration
[46:19] that will run your tests in a in a manner that makes more sense.
[46:24] Like, for instance, if for some reason you had a failure and then
[46:29] you make a change and then you upload it. With smart Orchestration, it
[46:31] will actually run that failure first to make sure if passes, versus you having
[46:37] to wait till like if it was like test nine nine a thousand that failed,
[46:39] you don't have to kill the entire suite to go through again. Yeah,
[46:43] so some smart Yeah, it's smart things to put the problems should up
[46:46] front, keep that cycle time down. Yeah. And I'm looking at the
[46:50] pricing like that's pretty reasonable. You consider how much the test edition of Studio
[46:55] costs back in the day for the business, this product being three thousand dollars
[47:01] a year for forty devs. That I'm not going to argue with that.
[47:06] That's pretty powerful stuff. And you only have to beat down one bad bug
[47:13] and you paid for your test suite for the year. Gay, you know
[47:15] that that's I look at that number and go you can burn that in a
[47:19] weekend with four davs tearing their hairs out trying to fix a problem, right,
[47:23] Like, if the tool can nail that down, at least let your
[47:27] roll back so you keep your weekend and you'll figure it out on Monday,
[47:30] or can actually get it too fixed so that they don't they don't spend the
[47:35] whole weekend of fighting it. I'm all for that, yep. Indeed awesome.
[47:38] So what's next? What's on the horizon for you? Cyprus thirteen?
[47:45] Cyprus thirteen yep. So right now, we're definitely looking at ways to make
[47:51] the developer experience of Cyprus better, and so that's a big focus of upcoming
[47:54] thirteen release, which is probably gonna be slated for the fall sometime. So
[47:58] we're looking a lot of API changes for stuff that the community is looking for.
[48:05] But only one major version every year, how slack? Yeah your reputation,
[48:13] Yeah, well your marketing people do only once that logos to make.
[48:17] But yeah, also continuing like to make the developer experience of component testing better,
[48:23] because that's one thing that people originally fell in love with the Cyprus is
[48:27] that the developer experience, like writing test before was kind of painful, not
[48:30] really all that fun. You can get up and running testing with Cyprus in
[48:34] like minutes, and it's a little relaxing to sit there and be able to
[48:37] write like tests over and over that aren't like stressing you mentally that are passing
[48:42] and all that kind of fun stuff. And so that's we're kind of really
[48:45] die hard at just making it as simple as possible to write tests. Very
[48:51] good, all right, Anything that we missed that you want to mention any
[48:54] shout outsh no, I don't think so, Okay, Yeah, awesome,
[49:00] Eli, Thanks thanks a lot. This is good stuff and great and thanks
[49:02] for answering our questions and it sounds like a great product again. Absolutely,
[49:07] guys, my pleasure, all right, and we'll talk to you next time
[49:10] on dot net rocks. Dot net Rocks is brought to you by Franklin's Net
[49:37] and produced by Pop Studios, a full service audio, video and post production
[49:42] facility located physically in New London, Connecticut, and of course in the cloud
[49:46] online at pwop dot com. This is our website at d O t n
[49:52] et r ocks dot com for RSS feeds, downloads, mobile apps, comments,
[49:58] and access to the full archives going back to show number one, recorded
[50:01] in September two thousand and two. And make sure you check out our sponsors.
[50:07] They keep us in business. Now go write some code. See you
[50:09] next time you got a chad metal band.

Shows are listed from Apple Podcasts' charts and directory, and Podcast Index where it is used. Every show and episode belongs to its publisher and plays from the publisher's own feed; this site hosts none of them.
