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

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