-
Notifications
You must be signed in to change notification settings - Fork 0
Tests
To test the website code, and collect coverage results, the project uses Jest (alongside React Testing Library).
To run the project tests, and collect coverage results into coverage-results folder, run
npm test
which is an alias to jest
command (check package.json scripts object). So, if Jest is globally installed in your machine, running
jest
will have the same result. If it is only locally installed (in the node_modules of the project), running
npx jest
will have the same result.
Project's Jest configuration is stored in the jest.config.ts file, in the root directory. bail
option is interesting for CI solutions, as Jest stops at first test failed.
To write a TODO in a test, use
it.todo('message');
inside describe
/test
block.
To run an individual test file, run
npx jest path/to/file.test.tsx
To run jest in watch mode, pass the --watch
flag.
To run jest without collecting coverage results, pass the --coverage=false
flag.
For more information, check Jest CLI Options.