Home

Awesome

jest-watch-exec

NPM version NPM downloads

Circle CI Travis CI Codecov Coveralls Status

Greenkeeper Semantic Release

Visual Studio Code Wallaby.js

Execute commands on start or when the all tests pass.

Requires jest@23+.

Usage

To use jest-watch-exec, add it to the watchPlugins section of the Jest configuration:

{
  "jest": {
    "watchPlugins": [
      ["jest-watch-exec", { "on-start": "npm run build" }],
      ["jest-watch-exec", { "on-start-script": "somescript.js" }],
      // Will run the `run(): boolean | Promise<boolean>` method exposed by the module
      ["jest-watch-exec", { "on-start-module": "modulescript.js" }],
      // Will run test even if on-start | on-start-script | on-start-module fails.
      ["jest-watch-exec", { "on-start-ignore-error": true, ... }],
      // execute script when there are passing tests.
      // will not execute if the tests are filtered.
      ["jest-watch-exec", { "on-pass": "npm run build" }],
      // execute 'on-pass' even the tests are filtered.
      ["jest-watch-exec", { "on-pass": "npm run build", "exec-while-filtered": true }]
    ]
  }
}

Contribute

# after fork and clone
npm install

# begin making changes
git checkout -b <branch>
npm run watch

# after making change(s)
git commit -m "<commit message>"
git push

# create PR