From the course: End-to-End JavaScript Testing with Cypress.io
Unlock this course with a free trial
Join today to access over 24,100 courses taught by industry experts.
Solution 2: Writing your own tests
From the course: End-to-End JavaScript Testing with Cypress.io
Solution 2: Writing your own tests
(upbeat electronic music) - [Instructor] All right, so hopefully you gave this challenge a try. Let's take a look at the solution. All that I did for this solution is I simply added on to this first test case here. You obviously could have created your own test case. But what I did is before double-clicking that item, I actually single-clicked it and made that assertion there, so let's actually create an alias for this thing since we're accessing it a few times. What we're going to do is we're going to say, cy.get, and then we're going to say .as, and then we'll say something like, thirdItem, and now we can simply refer to it as thirdItem so what we're going to do is we're going to say, cy.get, and we're going to say that we want to click on the thirdItem, all right? So that was the first thing, and we don't need that eq(2) thing anymore since we're accessing the thirdItem already, and then we're going to say .click, and the second thing was to actually make sure that that item had…
Contents
-
-
-
-
-
(Locked)
Interacting with elements6m 6s
-
(Locked)
Triggering other actions8m 46s
-
(Locked)
Common assertions8m 46s
-
(Locked)
Automatic retries3m 21s
-
(Locked)
Debugging Cypress tests5m 41s
-
(Locked)
Setting environment variables6m 10s
-
(Locked)
Working with test doubles4m 34s
-
(Locked)
Challenge 2: Writing your own tests1m 20s
-
(Locked)
Solution 2: Writing your own tests3m 29s
-
(Locked)
-
-