Skip to content
| Marketplace
Sign in
Visual Studio Code>Testing>Run Related Jest TestsNew to Visual Studio Code? Get it now.
Run Related Jest Tests

Run Related Jest Tests

Nick Dawe

|
2 installs
| (0) | Free
Runs Jest tests on files related to given JS/TS files
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Run Related Jest Tests

Right-click a JavaScript/TypeScript file and run its related Jest tests, without leaving the editor or typing a command.

Features

  • Explorer & editor context menu — right-click any .js, .jsx, .ts, or .tsx file (in the File Explorer or in an open editor tab) and select Run Related Jest Tests.
  • Source Control context menu — right-click a changed file in the Source Control (SCM) sidebar and select Run Related Jest Tests (SCM) to test just what you've touched.
  • Automatic Jest resolution — walks up from the file's own directory to find the nearest node_modules/jest, then checks for a hoisted install above the workspace root (monorepos), and finally falls back to npx jest (covers pnpm's symlinked store and global installs) if nothing local is found.

Usage

  1. Open a JS/TS/JSX/TSX file, or select one in the File Explorer.
  2. Right-click and choose Run Related Jest Tests (or, for a pending change, right-click the file in the Source Control sidebar and choose Run Related Jest Tests (SCM)).
  3. A terminal named Jest opens and runs jest --findRelatedTests against that file.

Requirements

  • Jest must be installed somewhere resolvable from the file being tested (locally, hoisted in a monorepo, or available via npx/global install).
  • Node.js must be available on PATH for the npx fallback case.

Known Limitations

  • Test results are printed to a terminal, not surfaced through VS Code's Test Explorer or any programmatic UI.
  • Relies on Jest's built-in --findRelatedTests resolution, so it inherits whatever that flag does (and doesn't) match in a given project's Jest config.

Release Notes

See CHANGELOG.md for the full history. Highlights:

  • Automatic discovery of the nearest Jest install, including monorepo/hoisted layouts and an npx fallback.
  • Support for JS, JSX, TS, and TSX files.
  • A Source Control context-menu command for running related tests on changed files.

Contributing / Development

  1. npm install
  2. Press F5 in VS Code to launch the Extension Development Host and try the commands in a new window.
  3. npm run watch runs webpack in watch mode while you work.
  4. npm run lint and npm test before submitting changes (npm test compiles the extension and its tests, lints, then runs the Mocha suite via @vscode/test-electron).

To produce a .vsix package locally:

npm install -g @vscode/vsce
npm install
npm run compile
npm run package
npm run vscode:package

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft