课程: End-to-End JavaScript Testing with Cypress.io

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution 1: Writing your own tests

Solution 1: Writing your own tests

(upbeat music) - [Shaun] All right, well, hopefully you gave this challenge a try. Let's take a look at the solution. So the first thing to do, of course, was to create a new test file. I just said new file, and I called this one something like challenge-1.cy.js. And then what I did is I just copied some of the code over from one of the previous ones, such as the max character input to at least give myself a start. So I just pasted that in there and made a few modifications. The first thing, of course, was to actually visit the correct URL or path, in this case, since we already set a base URL, and that was challenge-1,, and let's also change the text up here. So for describe, we'll just say something like 'Challenge page functionality'. And the first thing here that we wanted to test was we wanted to make sure that when there was nothing in the text input, there was nothing that showed up in the message underneath. So here's how this worked. I started off by just saying it, and for…

内容