sajad torkamani

Using jest

Syntax

jest --watch <test-file-pattern>

Example

jest --watch userService.spec.ts

This will watch userService.spec.ts for changes and re-run the tests related to that file.

Using NPM script

Assuming you have a test:watch NPM script that looks like this:

{ 
  // other NPM scripts
  "test:watch": "jest --watch"
}

You can run

npm run test:watch -- <test-file-name>

Sources

Tagged: Jest

Leave a comment

Your email address will not be published. Required fields are marked *