Skip to content

Unit tests

Nick Watts edited this page Aug 3, 2023 · 9 revisions

Unit tests are located in the src directory side by side with the module that they test (the test for some-module.js should be named some-module.test.js and be located in the same directory as some-module.js).

To run tests, run yarn test from the root directory.

To watch for changes in files and automatically re-run tests after a file is changed, use yarn test --watch.

As part of the IRWG’s (Independent Release Working Group’s) effort to improve testing confidence, Terra UI is also shifting to greatly invest in unit tests, and reduce the reliance on end-to-end UI tests.

See:

Unit tests are expected for new and modified code.

More info in:

Coverage

New or modified code is expected to have 80% code coverage and 80% branch coverage, or better.

A coverage report for new code in a PR can be viewed in SonarCloud. Click the "x% Coverage" link in the SonarCloud PR comment or navigate to https://sonarcloud.io/component_measures?metric=new_coverage&selected=DataBiosphere_terra-ui&id=DataBiosphere_terra-ui&pullRequest=PR_NUMBER.

To generate a coverage report locally, run yarn test --coverage. To view the report in HTML format, open coverage/lcov-report/index.html.

Clone this wiki locally