How to troubleshoot a Cypress failure
Last Updated:
There are many different scenarios where Cypress end-to-end tests may fail. It’s important to understand both why and how to solve these issues. Test failures are blockers in GitHub Actions deployment workflows in every instance, so these solutions will help your code move forward. This guide documents how to manage Cypress test failures. Cypress tests run in the continuous integration pipelines in vets-website
and content-build
. The continuous integration build for a pull request can be seen in GitHub when viewing the commit log in the branch or when a PR is opened.
Before you begin
In vets-website
and content-build
, you should be able to run Cypress tests locally. The README
s in vets-website
(link) and content-build
(link) document how to start the applications locally and run Cypress tests.
Step-by-step guide
If your E2E test is not running, and is not set to skip, proceed directly to step 3.
Step 1: Inspect the failure artifacts
Navigate to the Currently Disallowed E2E Test Specs on VA.gov page for the continuous integration run that contains the failing test(s).
Click the Workflow link in the Workflow Disallowed column of the relevant test spec.
Find the failing test in the CI record and inspect the e2e test logs.
If you cannot determine the root cause of the failure from the CI logs, the next step is to recreate the failure locally.
Step 2: Recreate the failure locally and identify the root cause of failure
Start
vets-website
orcontent-build
as described in their respectiveREADME
s.Start Cypress in headed mode and search for the failing test.
Run the test and see if it fails.
If the test does not fail on the first try, it is likely that the test is flaky. In order to identify the cause of the flakiness, you will need to run the test in the loop as described in this document. This document also includes tips on how to manage flakiness.
If a
vets-website
test does not fail in a loop, the failure may be present only in the production build.To build the production build locally, run
yarn build --buildtype=vagovprod
.Alternatively, you can download the production build from the CI run artifacts (
vagovprod.tar.bz2
) and extract the build intovets-website/build/vagovprod
.
After building, start the production build with
node src/platform/testing/e2e/test-server.js --buildtype=vagovprod --port=3001
.Start Cypress and run the test as described in the
README
Proceed to Step 3.
Step 3: Implement a fix
Based on what you’ve learned, select the appropriate course of action below:
Help and feedback
Get help from the Platform Support Team in Slack.
Submit a feature idea to the Platform.