Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 1.18 KB

unit-tests.md

File metadata and controls

31 lines (22 loc) · 1.18 KB

Unit tests

Unit tests are run using ts-jest, which is basically a TypeScript loader for Jest.

Tests are by default executed for all packages at once. Simply run the following command in the root directory:

yarn test 

Hooks

We're using React Hooks Testing Library for testing hooks as it allows us to abstract from any component and focus on the hook directly. The library integrates seamlessly with Jest, therefore there's no need for any special treatment when running the tests.

WebStorm

To run tests within the WebStorm IDE, you have to make it read the Jest settings from the root package.json because by default it looks into a package.json that is closest to the spec file.

  1. Open the Run / Debug Configurations dialog
  2. Expand the Templates section
  3. Select the Jest template
  4. Set the Working directory: field to the root folder of the project
  5. Save the template by clicking the OK button

These steps will make Jest start in the root folder regardless of in which package you initiate the test. Jest will then pick the config from the root package.json.