Registryvsx-firsttrisvscode-jest-runner

@vsx-firsttris/vscode-jest-runner

Public
VSX CompatibleOXP Native: Planned

// Description

Run and debug Jest, Vitest, Node.js, Bun, Rstest and Deno tests with ease, right from your editor.

// Readme

Open VSX

#🧪 Jest & Vitest Runner

Run and debug tests with ease, right from your editor

Extension Example

Build Coverage VS Marketplace Version Open VSX Installs Rating License: MIT

OverviewFeaturesConfigurationKeyboard ShortcutsContributing


##🎯 Overview

A lightweight VS Code extension for running and debugging Jest, Vitest, Rstest, Node.js (native), Bun, Deno and Playwright tests directly in your editor. Works out-of-the-box with minimal configuration.

What's New? Try the new native Test Explorer with code coverage integration! Enable it by setting "jestrunner.enableTestExplorer": true in your VS Code settings.

⚠️ Important: The extension uses AST-based parsing to read configuration files. It supports static resolution of variables defined in the file and configuration wrappers (like defineConfig), but it does not execute the file (function calls are ignored). Complex runtime logic or external imports are not supported. If your configuration is too complex, you can set disableFrameworkConfig: true to rely on defaultTestPatterns.

🚧 Notice: The extension is currently undergoing major refactoring. If you encounter any issues or have questions, please don't hesitate to create a GitHub issue.

##✨ Features

###🚀 Run & Debug Experience

  • Run individual tests or entire test suites with a single click
  • 🐛 Debug tests with full breakpoint and variable inspection support
  • 📊 Generate coverage reports to analyze test coverage
  • 👀 Watch mode for automatic test re-runs during development
  • 📸 Snapshot updating with dedicated command

###📋 Multiple Access Points

  • 🖱️ Context menu in editor and explorer (right-click on tests)
  • 🔍 CodeLens annotations above test definitions (optional)
  • 🗂️ Test Explorer integration showing test hierarchy in dedicated panel
  • ⌨️ Command palette (Ctrl+Shift+P) with full command access
  • Keyboard shortcuts for quick test execution

###🎯 Smart Test Detection

  • 🤖 Automatic framework detection - distinguishes between Jest, Vitest, Rstest, Node.js, Bun, Deno, and Playwright tests
  • 🔍 Reads and applies include/exclude patterns (globs and regex) from framework configs for fine-grained control over which tests appear

###💼 Project Flexibility

  • 📦 Monorepo support for yarn & VS Code workspaces
  • ⚙️ Multiple configurations with glob-based config resolution
  • ⚛️ Create React App and similar abstraction layers
  • 🛠️ Framework support including Vite, Tanstack Start, Nx, Next.js, and NestJS

##⚙️ Configuration

The extension supports test coverage through VS Code's Test Explorer. When you run tests with coverage, the results are displayed directly in VS Code's coverage view.

Prerequisites

For Jest:

  • Coverage works out of the box! No configuration needed.

For Vitest:

  • Install a coverage provider:
npm install -D @vitest/coverage-v8
# or
npm install -D @vitest/coverage-istanbul
  • You only need to specify the coverage provider in vitest.config.ts:
// vitest.config.ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    coverage: {
      provider: 'v8', // or 'istanbul'
    },
  },
});

For Node.js Native Test Runner:

  • Coverage is supported natively via the --experimental-test-coverage flag (enabled by default for coverage runs).
  • No extra setup required!

For Bun:

  • Coverage works out of the box! (uses bun test --coverage)
  • No extra setup required.

Coverage Directory Detection

The extension automatically detects the coverage directory from your framework configuration:

  • Jest: Reads the coverageDirectory option from your Jest config
  • Vitest: Reads the reportsDirectory option from your Vitest coverage config
  • Node.js: Defaults to coverage/ directory (standard native behavior)

If not specified, it defaults to coverage/ in your project root.

Running Tests with Coverage

All coverage entry points use the same Coverage profile powered by VS Code's native coverage API.

Coverage via Test Explorer

  • Click the "Coverage" button (shield icon) in the Test Explorer panel
  • Coverage results appear in VS Code's Coverage panel (View → Testing → Show Coverage)
  • Inline decorations in the editor show covered/uncovered lines

Coverage via CodeLens / Command Palette

  • Use the CodeLens "Coverage" action (if enabled) above a test or suite
  • Or run the Command Palette command: "Jest: Run Test with Coverage"

Customize the test runner for your project:

SettingDescription
Jest Configuration
jestrunner.configPathPath to Jest config (relative to workspace folder, e.g. jest-config.json). Can be a string or a glob mapping object to support multiple Jest configs.Example with glob mapping: {"**/*.it.spec.ts": "./jest.it.config.js", "**/*.spec.ts": "./jest.unit.config.js"} - The first matching glob is used, so specify more specific patterns first. Config path is relative to jestrunner.projectPath or workspace root. Use jestrunner.useNearestConfig: true to search up directories for the matching config file.
jestrunner.jestCommandDefine an alternative Jest command for projects using abstractions like Create React App (e.g. npm run test --).
jestrunner.runOptionsCLI options to add to Jest commands (e.g. ["--coverage", "--colors"]). See Jest CLI documentation.
jestrunner.debugOptionsAdd or override VS Code debug configurations (e.g. { "args": ["--no-cache"] }). Only applies when debugging tests.
jestrunner.enableESMManually enable ESM support. When set to true, --experimental-vm-modules is added to NODE_OPTIONS. Default: false.
Vitest Configuration
jestrunner.vitestConfigPathPath to Vitest config (relative to workspace folder, e.g. vitest.config.ts). Can be a string or a glob mapping object similar to configPath.
jestrunner.vitestCommandDefine an alternative Vitest command (default: npx --no-install vitest).
jestrunner.vitestRunOptionsCLI options to add to Vitest commands (e.g. ["--reporter=verbose"]). See Vitest CLI documentation.
jestrunner.vitestDebugOptionsAdd or override VS Code debug configurations for Vitest (e.g. { "args": ["--no-cache"] }). Only applies when debugging Vitest tests.
Rstest Configuration
jestrunner.rstestCommandDefine an alternative Rstest command (default: npx --no-install rstest).
jestrunner.rstestRunOptionsCLI options to add to Rstest commands (e.g. ["--globals"]).
jestrunner.rstestDebugOptionsAdd or override VS Code debug configurations for Rstest. Only applies when debugging Rstest tests.
Node.js Test Configuration
jestrunner.nodeTestCommandDefine an alternative Node.js test command (defaults to node).
jestrunner.nodeTestRunOptionsCLI options to add to the Node.js test runner command (e.g. ["--experimental-test-coverage"]).
jestrunner.nodeTestDebugOptionsAdd or override VS Code debug configurations for local Node.js tests (e.g. { "args": ["--no-warnings"] }). Only applies when debugging node:test tests.
Bun Configuration
jestrunner.bunRunOptionsCLI options to add to Bun test command (e.g. ["--silent"]).
jestrunner.bunDebugOptionsAdd or override VS Code debug configurations for Bun (e.g. { "args": ["--no-cache"] }). Only applies when debugging bun tests.⚠️ Note: Debugging requires the Bun for Visual Studio Code extension.
Deno Configuration
jestrunner.denoRunOptionsCLI options to add to Deno test command (e.g. ["--allow-net"]).
jestrunner.denoDebugOptionsAdd or override VS Code debug configurations for Deno. Only applies when debugging deno tests.
Playwright Configuration
jestrunner.playwrightConfigPathPath to Playwright config (relative to workspace folder, e.g. playwright.config.ts).
jestrunner.disablePlaywrightDisable the Playwright test runner integration. Default: false.
jestrunner.playwrightCommandDefine an alternative Playwright command (default: npx playwright test).
jestrunner.playwrightRunOptionsCLI options to add to Playwright commands (e.g. ["--headed"]). See Playwright CLI documentation.
jestrunner.playwrightDebugOptionsAdd or override VS Code debug configurations for Playwright. Only applies when debugging Playwright tests.
UI Options
jestrunner.defaultTestPatternsFallback patterns used when no 'testMatch'/'testRegex' (Jest) or 'include' (Vitest) configuration is found. Default: ["**/*.{test,spec}.?(c|m)[jt]s?(x)", "**/__tests__/**/*.?(c|m)[jt]s?(x)"]
jestrunner.enableTestExplorerEnable the Test Explorer integration using VS Code's Testing API. Shows tests in dedicated Test Explorer panel. Default: false
jestrunner.enableCodeLensBring back the old CodeLens feature with inline run/debug buttons (replaced by Test Explorer). Default: true
jestrunner.codeLensSpecify which CodeLens actions to show when CodeLens is enabled. Options: "run", "debug", "watch", "coverage", "current-test-coverage". Default: ["run", "debug"]
jestrunner.preserveEditorFocusKeep focus on the editor instead of switching to the terminal when running tests.
Debugging
jestrunner.enableDebugLogsEnable debug logging to the "Jest Runner" output channel. Useful for troubleshooting test detection and configuration issues. Default: false
jestrunner.maxBufferSizeMaximum buffer size in MB for test output (default: 50MB).
Project Management
jestrunner.projectPathPath to project directory. Can be absolute (e.g. /home/me/project/sub-folder) or relative to workspace root (e.g. ./sub-folder).
jestrunner.changeDirectoryToWorkspaceRootChange directory before running tests. Priority order: 1. projectPath 2. nearest package.json location 3. workspace folder.
jestrunner.useNearestConfigIf true, the extension automatically searches for the nearest configuration file (e.g. jest.config.js or package.json) relative to the test file. Useful for projects with multiple configs or nested projects where no global config is set.Default: false (Strict Mode). By default, if configPath is empty, the extension passes no config argument to Jest, allowing native resolution (best for Monorepos).
jestrunner.disableFrameworkConfigIf true, the extension will ignore any framework configuration files (e.g. jest.config.js, vitest.config.ts) and use the jestrunner.defaultTestPatterns instead.

This updated configuration table now includes the Node.js Test Runner settings.

The extension automatically reads configuration from your framework config files.

⚠️ Important: The extension uses AST-based parsing to read configuration files. It does not execute the file as JavaScript/TypeScript code.

This means:

  • It cannot resolve external imports or complex runtime logic.
  • Variables are supported via static analysis as long as they are defined within the file.
  • Function Calls are not executed. Only configuration wrappers (like defineConfig) are supported.
  • Only a single configuration file is parsed. If you use config inheritance, ensure the file the extension reads contains the necessary patterns.

If your configuration is too complex for this parser, you can set jestrunner.disableFrameworkConfig: true. This will disable config parsing and the extension will rely solely on jestrunner.defaultTestPatterns to identify test files.

###🏗️ Projects Support

The extension supports the projects configuration for Jest, Vitest, and Rstest. This is essential for monorepos or multi-project workspaces.

  • Jest: Supports projects array defined as string paths (e.g. ['<rootDir>/packages/*']) or configuration objects.
  • Vitest: Supports projects array in your config file or vitest.workspace.ts exporting an array of project configurations.
  • Rstest: Supports projects as an array of config objects or relative config paths.

The extension will recursively parse these project configurations to identify test files across your entire workspace.

###Jest Config Options

OptionTypeDescription
rootDirstringRoot directory for resolving paths
rootsstring[]Directories to search for test files (e.g., ["<rootDir>/src", "<rootDir>/tests"])
testMatchstring[]Glob patterns for test files (e.g., ["**/*.test.ts"])
testRegexstring | string[]Regex patterns for test files
testPathIgnorePatternsstring[]Regex patterns to exclude files (e.g., ["/fixtures/", "/node_modules/"])
projectsstring[] | object[]List of projects or paths to project config files

Example Jest Config:

// jest.config.js
module.exports = {
  rootDir: '.',
  roots: ['<rootDir>/src', '<rootDir>/tests'],
  testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
  testPathIgnorePatterns: ['/node_modules/', '/fixtures/', '/__mocks__/'],
};

###Vitest Config Options

OptionTypeDescription
rootstringProject root directory
test.dirstringBase directory for test file discovery
test.includestring[]Glob patterns for test files (e.g., ["**/*.test.ts"])
test.excludestring[]Glob patterns to exclude (e.g., ["**/e2e/**"])
projectsobject[] | string[]List of project configurations (or workspace array)

Example Vitest Config:

// vitest.config.ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  root: '.',
  test: {
    dir: 'src',
    include: ['**/*.{test,spec}.{js,ts,jsx,tsx}'],
    exclude: ['**/node_modules/**', '**/e2e/**', '**/fixtures/**'],
  },
});

###Node.js Native Runner

The Node.js test runner does not use a specific configuration file in the same way Jest or Vitest do. Instead, it relies on glob patterns or file naming conventions.

  • By default, the extension looks for files matching: **/*.{test,spec}.?(c|m)[jt]s?(x) and **/__tests__/**/*.?(c|m)[jt]s?(x).
  • You can customize this by modifying jestrunner.defaultTestPatterns in your VS Code settings.

###Playwright Config Options

OptionTypeDescription
testDirstringBase directory for Playwright test discovery
testMatchstring | string[] | RegExpFile matching pattern(s) for Playwright tests
testIgnorestring | string[]Pattern(s) to exclude from discovery

Example Playwright Config:

// playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: './tests',
  testMatch: ['**/*.spec.ts'],
  testIgnore: ['**/fixtures/**'],
});

###Rstest Config Options

OptionTypeDescription
rootstringRoot directory used to resolve test paths (__dirname is supported)
includestring[]Glob patterns for test discovery
excludestring[] | { patterns: string[] }Glob patterns to exclude from discovery
projectsstring[] | object[]Multi-project setup with relative config paths or inline project configs

Example Rstest Config:

// rstest.config.ts
export default {
  root: '__dirname',
  include: ['src/**/*.test.ts', 'tests/**/*.spec.ts'],
  exclude: ['**/fixtures/**', '**/node_modules/**'],
  projects: [
    './packages/app/rstest.config.ts',
    {
      include: ['packages/lib/**/*.test.ts'],
      exclude: { patterns: ['**/legacy/**'] },
    },
  ],
};

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"]
}

nvm

"jestrunner.jestCommand": "nvm use && npm run test --",
"jestrunner.debugOptions": {
    "runtimeExecutable": "/PATH/TO/YOUR/node"
}

ESM (ECMAScript Modules)

ESM support is now opt-in. To enable it, set "jestrunner.enableESM": true in your settings. This will automatically add --experimental-vm-modules to NODE_OPTIONS for debugging.

The extension fully supports Jest's parameterized tests using it.each and describe.each. These allow you to run the same test logic with different inputs, making your tests more concise and maintainable.

In the test names, you can use template variables like %s (string), %i (integer), %f (float), etc., which Jest replaces with the actual parameter values for better readability.

Jest Example

it.each([
  ['apple', 5],
  ['banana', 6],
  ['cherry', 6],
])('should return correct length for %s', (fruit, expectedLength) => {
  expect(fruit.length).toBe(expectedLength);
});

Vitest Example

import { describe, it, expect } from 'vitest';

it.each([
  { input: 'hello', expected: 5 },
  { input: 'world', expected: 5 },
])('length of $input is $expected', ({ input, expected }) => {
  expect(input.length).toBe(expected);
});

Dynamic Test Names

You can also use dynamic test names derived from class method names:

class TestClass {
  myFunction() {
  }
}
it(TestClass.prototype.myFunction.name, () => {
  expect(true).toBe(true);
});
  1. Open Command PalettePreferences: Open Keyboard Shortcuts (JSON)
  2. Add the following shortcuts:
{
  "key": "alt+1",
  "command": "extension.runJest"
},
{
  "key": "alt+2",
  "command": "extension.debugJest"
},
{
  "key": "alt+3",
  "command": "extension.watchJest"
},
{
  "key": "alt+4",
  "command": "extension.runPrevJest"
}

##🤝 Contributing

Want to start contributing features? Check out our open issues to get started!

###🚀 Development Setup

  1. Clone the repository
  2. Install dependencies
  3. Start debugging
  • Press F5 or go to RunStart Debugging
  • A new VS Code window will open with the extension loaded

Made by the open source community

⭐ Star us on GitHub • 🐛 Report a Bug • 💡 Request a Feature

// Install

Open this extension directly in your IDE — no CLI, no extra tools.

Extension ID
firsttris.vscode-jest-runner

If your IDE doesn't open automatically, copy the ID above and paste it into the Extensions view (⌘P ext install <id>).

// Source signals

Publisher
Verified ✓
Rating
5.0 (1)
Downloads
786.5k
Published
2026-04-21
License
MIT
Source
repo
Homepage
link

Live from open-vsx.org. Refreshed hourly.

// Are you the author?

This listing is mirrored from Open VSX. Claim it to ship a native OXP build, customise the page, and respond to reviews.

Claim this listing

// Package Info

Version
0.4.148
Owner
@vsx-firsttris
Downloads
776.6k
Stars
0