Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including jest-watch-exec with all npm packages installed. Try it out:

require("jest/package.json"); // jest is a peer dependency. var jestWatchExec = require("jest-watch-exec")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

jest-watch-exec v1.4.1

Execute script when test passes in watch mode


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+.


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" }],
      // Will run test even if the script throws an error.
      ["jest-watch-exec", { "on-start": "npm run build", "on-start-ignore-error": true }],
      ["jest-watch-exec", { "on-start-script": "somescript.js" }],
      // Will run test even if the script throws an error.
      ["jest-watch-exec", { "on-start-script": "somescript.js", "on-start-ignore-error": true }],
      // 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 the script returns:
      // - a falsy value,
      // a promise resolves to false,
      // or a rejected promise.
      ["jest-watch-exec", { "on-start-module": "modulescript.js", "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" }],
      // 'exec-while-filtered' applies to 'on-pass'
      ["jest-watch-exec", { "on-pass": "npm run build", "exec-while-filtered": true }]


# 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
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free