To run the tests make sure that the node_modules are installed with yarn install
and then run yarn test
. To test an individual file yarn test src/test/file-name.js
.
Tests are run with Jest and use a behavior-driven testing style, with plain language descriptions.
describe('the thing to be tested', function() {
it('does some piece of work', function() {
expect( ... ).toEqual(...);
})
})
Assertions are written using Jest's own Library.
We use async
/await
to test asynchronous code. We also sometimes use sinon's mock library
when Jest's mocking capabilities are falling short. This should be used as a last resort only because better solutions usually exist.
Test type | Description |
---|---|
components | Snapshot tests for React components (experimental). Full component testing is planned as well. |
store | Testing the Redux store using actions and selectors. |
unit | Unit testing |