Using Cypress for end-to-end testing
Cypress is a focused, end-to-end testing framework that also comes with the ability to test individual UI components. It tries to be different by mostly avoiding browser automation. Instead, its test runner is located directly inside the browser.
To use Cypress, you need to install the cypress
package from npm:
$ npm install cypress --save-dev
This allows you to use the cypress
command-line utility. Ideally, run it with npx
as we did with the other tools:
$ npx cypress open
Cypress is at its heart a graphical tool. As such, we are first introduced to a small configurator that allows us to set up our project. The configurator is shown in Figure 7.2. Picking E2E Testing will give you the ability to influence what files are written:
Figure 7.2 – The Cypress configurator on opening it for the first time
The configurator also lets you pick a browser where the tests should actually be run. Right now, Chrome...