Unit And Integration Tests

Unit And Integration Tests

In this guide:

  1. Jest setup

  2. Integration tests

  3. Unit tests

Integration tests

Integration tests are performed when deploying to your dev stack as part of the MR pipeline. See {link to revised MR and pipeline doc}

Unit tests

Unit tests are preferred over Integration tests as data changes constantly. Unit tests can be executed locally and faster than integration tests.

To run locally:

Run all unit tests

yarn test

Run a specific unit test

General form:

yarn jest ./tst/path/to/specific/UnitTest.test.ts

Specific example:

yarn jest ./tst/unit/utils/AllocateTreatment.test.ts

Set up Jest for new packages

For reference, see the following examples:

See the following configuration files for this package for running unit tests locally using Jest:

[jest.config.js](https://gitlab.aws.dev/amazonmusic/musicfirefly/amu_webapi/-/blob/main/jest.config.js)
[tsconfig.json](https://gitlab.aws.dev/amazonmusic/musicfirefly/amu_webapi/-/blob/main/tsconfig.json)
[package.json](https://gitlab.aws.dev/amazonmusic/musicfirefly/amu_webapi/-/blob/main/package.json) (the "test" script and dependencies)