Writing your first E2E test
Once Cypress has been properly configured for E2E testing, we can get down to business. Let’s take a look at how to write our first E2E test:
- Now that Cypress is installed and configured, you can start writing your first test. You can click on Create new spec in this interface as shown in Figure 7.11:
Figure 7.11 – Spec creation interface in Cypress
- After doing that, you can see in Figure 7.12 a new file named
spec.cy.ts
, created in thee2e
folder of your project’scypress
folder:
Figure 7.12 – Spec file
This file contains the following:
Figure 7.13 – The source code of our spec file
- Now, you may be faced with a surprise when you return to the browser where the E2E test is launched as shown in Figure 7.14:
Figure 7.14 – The E2E test failed due to a compilation error...