Home

Awesome

vscode-jest-runner

Looking for collaborators to help me maintain the project. Please contact me at tristanteufel@gmail.com

Visual Studio Code Marketplace

VisualStudio Marketplace Open VSX Registry

Comparison with vscode-jest

vscode-jest-runner is focused on running or debugging a specific test or test-suite, while vscode-jest is running your current test-suite everytime you change it.

Features

Simple way to run or debug a specific test As it is possible in IntelliJ / Webstorm

Run & Debug your Jest Tests from

Supports

Extension Example

Usage with CRA or similar abstractions

add the following command to settings:

"jestrunner.jestCommand": "npm run test --",
"jestrunner.debugOptions": {
    "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
    "runtimeArgs": [
      "test",
      "${fileBasename}",
      "--runInBand",
      "--no-cache",
      "--watchAll=false",
      "--color"
    ]
},

Extension Settings

Jest Runner will work out of the box, with a valid Jest config. If you have a custom setup use the following options to customize Jest Runner:

CommandDescription
jestrunner.configPathJest config path (relative to ${workspaceFolder} e.g. jest-config.json)
jestrunner.jestPathAbsolute path to jest bin file (e.g. /usr/lib/node_modules/jest/bin/jest.js)
jestrunner.debugOptionsAdd or overwrite vscode debug configurations (only in debug mode) (e.g. "jestrunner.debugOptions": { "args": ["--no-cache"] })
jestrunner.runOptionsAdd CLI Options to the Jest Command (e.g. "jestrunner.runOptions": ["--coverage", "--colors"]) https://jestjs.io/docs/en/cli
jestrunner.jestCommandDefine an alternative Jest command (e.g. for Create React App and similar abstractions)
jestrunner.disableCodeLensDisable CodeLens feature
jestrunner.codeLensSelectorCodeLens will be shown on files matching this pattern (default **/*.{test,spec}.{js,jsx,ts,tsx})
jestrunner.codeLensChoose which CodeLens to enable, default to ["run", "debug"]
jestrunner.enableYarnPnpSupportEnable if you are using Yarn 2 with Plug'n'Play
jestrunner.yarnPnpCommandCommand for debugging with Plug'n'Play defaults to yarn-*.*js
jestrunner.projectPathAbsolute path to project directory (e.g. /home/me/project/sub-folder), or relative path to workspace root (e.g. ./sub-folder)
jestrunner.changeDirectoryToWorkspaceRootChanges directory before execution. The order is:<ol><li>jestrunner.projectPath</li><li>the nearest package.json</li><li>${workspaceFolder}</li></ol>
jestrunner.preserveEditorFocusPreserve focus on your editor instead of focusing the terminal on test run
jestrunner.runInExternalNativeTerminalrun in external terminal (requires: npm install ttab -g)

Shortcuts

Command Pallette -> Preferences: Open Keyboard Shortcuts (JSON) the json config file will open add this:

{
  "key": "alt+1",
  "command": "extension.runJest"
},
{
  "key": "alt+2",
  "command": "extension.debugJest"
},
{
  "key": "alt+3",
  "command": "extension.watchJest"
},
{
  "key": "alt+4",
  "command": "extension.runPrevJest"
}

Want to start contributing features?

Check some open topics get you started

Steps to run Extension in development mode

Another vscode instance will open with the just compiled extension installed.