Solution: e2e Tests

Here’s the solution of how to write e2e tests with Cypress and Cypress testing library.

We'll cover the following

Solution

Your task was to create tests using Cypress and Cypress testing library. Here are the required steps:

For the tests/e2e/specs/website.js file:

Home tests

  • Visit the homepage and confirm it contains a headline with the Welcome to The Road To Enterprise text.

About tests

  • Click on the About nav link and confirm that the Welcome to The Road To Enterprise text isn’t present.
  • Check that the About page contains the About Us text.

Contact tests

  • Click on the Contact nav link.
  • Load the contactData.json fixture.
  • Fill in the form using the data loaded from the fixture.
  • Click on the Send button.
  • Confirm that the page contains Message sent text and the email and message texts from the fixture.

Let’s run the following code to understand how the solution above works.

Note: The code below may take a while to run. When the server starts, go to the app URL to see the output.

Get hands-on with 1200+ tech skills courses.