About

Install

For TypeScript install Jest with ts-jestarrow-up-right preprocessor with:

npm install --save-dev jest @types/jest ts-jest

Because we are running with ts-jest create the jest.config.js file, which will inform Jest how to handle .ts files correctly.

npx ts-jest config:init

Test files for Jest are named <file>.test.ts.

By specific filename

Specific filename AND path

Run only the tests that were specified with their exact paths.

npx jest --runTestsByPath [path]/[filename]

Specific filename

Find and run the tests that cover a space separated list of source files.

It will regex only by the specified name, so if multiple files have the same name it will execute all of them.

With coverage

On watch mode

Watch files for changes and rerun tests.

To rerun only changed files

To rerun all files

Last updated