Testing
Unit Tests
As a standard practice we do not write unit tests for the front-end code, however there is a strict requirement for E2E tests to be written for all new features and bug fixes.
E2E Tests
Running E2E Tests
Local Development Environment
When running the E2E tests against your local development environment, where you are running the front-end server directly, you can run the E2E tests by running the following commands:
Run the web server:
yarn dev
Run the E2E tests:
yarn test:e2e:run-node-local
This will run all of the E2E tests against your local development environment.
If you want to run just a few tests, or see the tests explicitely running in a browser, you can open the E2E tests by running the following command:
yarn test:e2e:dev-node-local
Docker
To run all fo the E2E tests in a Docker container, run the following command:
yarn test:e2e:run
To run the E2E tests in a Docker container and see the tests explicitely running in Cypress for debugging, run the following command:
yarn test:e2e:dev
Github "E2E Tests" Workflow
The E2E Tests workflow run on a nightly schedule, using a larger GitHub runner instance.
The workflow is scheduled to run at midnight and an issue will be created if the test fails, all committers since the last successful test will be mentioned on the issue. A Slack message will be sent to #ops-frontend-e2e for each nightly run to ensure visibility on the results.
When a reviewer is ready to merge a PR to main, they should manually run the E2E Tests workflow as a final test.
Writing E2E Tests
Defining Selectors
We use a couple of tools that require easy selection/searching of DOM node elements in our rendered content. We have a standard for tagging DOM elements with data- attributes to make node selection easier. These standards are also shared for DOM selection in PostHog, and the details can be found on the Data Attributes page.

