课程: End-to-End JavaScript Testing with Cypress.io
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
The and command
- [Instructor] All right, so the next command that we're going to take a look at with Cypress is a command called and, and really the only purpose of this one is to increase the readability of your tests. So let's say, first of all that, and I'm just going to add it onto this results.cy.js file because we're already here. All right so to demonstrate this, let's say that we want to make more than one assertion about this character's left thing here, right? Let's say that in addition to checking that its value equals something, we also just want to check to see if it exists explicitly. So what that would look like if we created a chain here is we could say, Cy.get characters left, blah, blah, blah. And then we can say, .should exist. And then we would say, .should equal 15. Alright? So that's how that would look. And if we go back and take a look at our test here, we'll see that that passes, of course, because it exists. You can see that case right there. But in many cases, people want…