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

免费学习该课程!

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

Setting a base URL

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…

内容