Skip to main content

Writing tests

All new code must have at least 65% code coverage. This is enforced by the CI pipeline.

Unit Testing

We use Jest for unit testing. Unit tests should be located in a __tests__ directory next to the code they are testing and should be named *.test.ts.

The recommended way to start writing a new test is to first copy and existing test file and move it into the appropriate directory.

Follow the Jest docs for more detailed information on how to write tests.

When testing components you should include a snapshot test and an accessibility test along with at least one other functional test at a minimum.

Run the tests with:

pnpm test

or

pnpm run test --filter=@overdose/<PACKAGE_NAME>

End-to-end Testing

We use Playwright for end-to-end testing. Follow the Playwright docs for more information on how to write tests.

E2E tests are located in pwa/apps/carrots-frontend/__tests__ and should be named *.spec.ts.

To run all e2e tests, run:

pnpm test:e2e --filter=@overdose/carrots-frontend