Skip to content

Latest commit

 

History

History
49 lines (30 loc) · 2.47 KB

run-tests.md

File metadata and controls

49 lines (30 loc) · 2.47 KB

Run tests

The LetsGo monorepo uses the Jest test framework for individual components and packages. In addition, test running is streamlined through the turborepo's incremental build logic, which allows you to quickly run tests for only those components that have changed.

Prerequisites

Before running tests, satisfy the same prerequisites as for running your app locally.

Side effects

There is a variety of tests in the LetsGo monorepo, from simple API-level tests to integration tests that cut through many layers of the app all the way to the database.

Some tests will write data to the database. While all tests make the best effort to clean up after themselves and not affect artifacts they have not created, it is not a good idea to run tests in the production environment once you have live customers, unless you know exactly what you are doing.

See how to manage multiple deployments to address this issue by isolating your production and development environments.

Run tests globally

You can run all tests in the monorepo from the root directory of your project with the following command:

yarn test

This will run tests for all components of the monorepo that have a test script defined in their package.json file. Note that this mechanism uses the turborepo's incremental build logic, which means that tests will be skipped for components that have not changed (and their dependencies have not changed) since the last test run. If you want to override this logic and force all tests in the monorepo to run regardless of any changes, use this command instead:

yarn test --force

You can also selectively run tests for only one component using the --filter option, e.g.:

yarn test --filter api --force
yarn test --filter @letsgo/trust

The parameter you provide to --filter is the name of the component from its package.json file.

Run tests for individual components

You can also run tests for individual components of your app by issuing the yarn test command from that component's directory:

cd packages/trust
yarn test

This mechanism does not use turborepo's incremental build logic and instead simply executes the test script from package.json. It is often a more convenient way of running tests for the component you are currently working on.