Implementing end-to-end tests with Cypress
Cypress is an end-to-end testing tool that works really well for single-page applications (SPAs) like ours. Cypress can run the whole application, simulate a user interacting with it, and check the state of the user interface along the way. So, Cypress is ideal for producing end-to-end tests on a SPA.
In this section, we are going to implement an end-to-end test for signing in and asking a question.
Getting started with Cypress
Cypress executes in our frontend, so let's carry out the following steps to install and configure Cypress in our frontend project:
- We'll start by installing
cypress
from the Terminal:> npm install cypress --save-dev
- We are going to add an
npm
script to open Cypress by adding the following line topackage.json
:"scripts": { ..., "cy:open": "cypress open" }...