课程: End-to-End JavaScript Testing with Cypress.io
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Setting a base URL
- [Instructor] Alright, well so far in our code, whenever we've wanted to visit a page as we have in our end-to-end tests here, what we've had to do is we've had to say cy.visit followed by the entire URL, and only then do we actually have the path that we're interested in. So as you can see through multiple tests, we've had to actually write out that entire URL over and over again, even though the only part that's ever going to change in our case is going to be that very end part, the /example-1 or /example-2, et cetera. Now, if you have a large number of tests, it would be kind of silly to have to have this base URL over and over again in each test. And as a matter of fact, Cypress allows us to specify a base URL for our project so that instead of typing out the full URL each and every time, we can just type the path that we want to visit, right? So we could just say cy.visit('example-2'); for example. The way that we do this is by opening this cypress.config.js file that Cypress…
内容
-
-
-
-
Installing and running Cypress2 分钟 14 秒
-
Writing and running Cypress tests8 分钟
-
(已锁定)
Testing text inputs7 分钟 53 秒
-
(已锁定)
Selecting elements8 分钟 20 秒
-
(已锁定)
Element aliasing6 分钟 39 秒
-
(已锁定)
Working with command results5 分钟 43 秒
-
(已锁定)
Using beforeEach4 分钟 57 秒
-
(已锁定)
Setting a base URL3 分钟 29 秒
-
(已锁定)
Challenge 1: Writing your own tests1 分钟 46 秒
-
(已锁定)
Solution 1: Writing your own tests6 分钟 38 秒
-
-
-
-