I'm visiting an application, and then I'm selecting an element, typing into it, hitting enter, and then doing some actions again. Getting an element, clicking, typing, interacting with my page. Basically, what I want to do is to go to my homepage, create a new board, then create a new list, and inside it, create a new card. And this is what the flow automates.
So, whenever I make an error, for example, I change my selector to not be found, and when I save my test, it will automatically rerun. If I make an error during my test, I get this really nice assertion error explaining to me what actually happened. So in this case, what actually happened is that it couldn't find the selector because I made a typo on it and it was nowhere to be found. Cypress is actually going to retry searching for that selector for 4,000 milliseconds, so for four seconds.
Now, this means that Cypress works really great for the applications that are all the time re-rendering and doing some sort of fetching from API, etc. as modern applications do. So when you are testing, you get this instant feedback into what your test has done. But also, the important thing here is that we are running inside the browser. So while we are doing that, we get all of the advantages that the browser will provide us. So for example, we can open up a console and take a look into what's happening inside the console. So I'm getting a couple of warnings here, but these are not that important. Cypress actually takes a great advantage of the console and of the fact that we are running inside the browser. So when I click on any of my commands, for example this visit command, Cypress will print out information into the console with the details of that command. It will also print out information for every HTTP request that is being done with the application. So let's maybe fix the test, save it to make it pass. And also, what Cypress enables us, as you can see, is to travel back in time and examine the application as it was looking while the test was being executed. This is pretty neat, this gives you an insight, especially if you're looking for a selector that is kind of hard to find because the element appears and then it disappears. This is a really, really helpful tool. So you can see different API calls, and Cypress sort of invites you to get into the application and examine the application and get to know its nuts and bolts. So a great area to start examining your application a little bit more is to do API testing, and this is actually a second part of our circle of tests.
So when we are doing API testing in Cypress, we can use a command called request, so let me show you that one. And let's change it because I'm going to show you the API command in just a second. So let me save my test and let me open that in my Cypress runner. Oops, sorry, that was not the correct test. We want to run the API testing. So now we have it.
Comments