This repository is set up for testing with Jest (ts-jest to be precise), automated through npm.
Note how Jest is set up in package.json
: It adds development dependencies for jest
, ts-jest
and @types/jest
(all three needed for Jest in TypeScript). It also adds a test
script to tell npm what to execute with npm test
.
Finally jest.config.js
indicates to Jest where to find the tests.
You will likely want to explore IDE integration for test execution and coverage in your IDE, but also ensure that tests still execute with npm in a Continuous Integration environment (e.g. github actions).
The following commands might be useful:
npm install
install all dependencies, including TypeScript and Jest.npm test
runs jest and prints a coverage report. It also creates a html report incoverage/lcov-report/index.html
npx jest --watch --collect-coverage
runs Jest from the command line with extra arguments, here to continue watching for changes (will rerun tests immediately when changes in files are detected) and reporting coverage