New to Claude Skills? Learn how to install them →

microsoft on GitHub

Unit Tests

OfficialFree

Efficiently run and manage unit tests in VS Code.

by microsoft188.6k stars on microsoft/vscode
2 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What Unit Tests does

The Unit Tests skill is designed for developers working with the Visual Studio Code (VS Code) repository. It provides a streamlined way to execute unit tests using the runTests tool, which offers structured output and detailed pass/fail information. This tool is preferred for running tests due to its ability to filter tests by file and name, as well as collect coverage data. The skill also supports running tests from specific files or using glob patterns, making it versatile for different testing scenarios.

For environments where the runTests tool is unavailable, the skill offers fallback options through platform-specific shell scripts. Developers can utilize scripts/test.sh for macOS and Linux or scripts/test.bat for Windows to initiate tests. These scripts handle the necessary setup, including downloading Electron if required, and launching the Mocha test runner. This ensures that tests can be run consistently across different operating systems.

The skill includes various commonly used options that enhance the testing process. Users can specify file paths directly, filter tests by name, and even generate coverage reports. Additionally, it allows for setting custom timeouts for long-running tests. This flexibility is crucial for maintaining efficient testing workflows, especially in larger projects where specific tests need to be targeted.

Overall, the Unit Tests skill is essential for developers looking to effectively manage and execute unit tests within the VS Code ecosystem. It simplifies the testing process and helps ensure that code changes are validated promptly and accurately.

When to use it

Use this skill when working on unit tests in the VS Code repository to streamline execution and reporting.

When not to use it

This skill is not suitable for integration tests, which require a different execution method.

What you can build with it

Running a Specific Test

Use the `runTests` tool to execute a specific test by passing its file path and the test name.

Generating Coverage Reports

Run tests with the `--coverage` option to generate a coverage report for your code.

Filtering Tests by Pattern

Utilize the `--grep` option to run only those tests that match a certain naming pattern.

How to install Unit Tests

View source

1. Install with the skills CLI

npx skills add microsoft/vscode/unit-tests --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by microsoft

Running Unit Tests

Preferred: Use the runTests tool

If the runTests tool is available, prefer it over running shell commands. It provides structured output with detailed pass/fail information and supports filtering by file and test name.

  • Pass absolute paths to test files via the files parameter.
  • Pass test names via the testNames parameter to filter which tests run.
  • Set mode="coverage" to collect coverage.

Example (conceptual): run tests in src/vs/editor/test/common/model.test.ts with test name filter "should split lines".

Fallback: Shell scripts

When the runTests tool is not available (e.g. in CLI environments), use the platform-appropriate script from the repo root:

  • macOS / Linux: ./scripts/test.sh [options]
  • Windows: .\scripts\test.bat [options]

These scripts download Electron if needed and launch the Mocha test runner.

Commonly used options

Bare file paths - Run tests from specific files

Pass source file paths directly as positional arguments. The test runner automatically treats bare .ts/.js positional arguments as --run values.

./scripts/test.sh src/vs/editor/test/common/model.test.ts
.\scripts\test.bat src\vs\editor\test\common\model.test.ts

Multiple files:

./scripts/test.sh src/vs/editor/test/common/model.test.ts src/vs/editor/test/common/range.test.ts

--run <file> - Run tests from a specific file (explicit form)

Accepts a source file path (starting with src/). The runner strips the src/ prefix and the .ts/.js extension automatically to resolve the compiled module.

./scripts/test.sh --run src/vs/editor/test/common/model.test.ts

Multiple files can be specified by repeating --run:

./scripts/test.sh --run src/vs/editor/test/common/model.test.ts --run src/vs/editor/test/common/range.test.ts

--grep <pattern> (aliases: -g, -f) - Filter tests by name

Runs only tests whose full title matches the pattern (passed to Mocha's --grep).

./scripts/test.sh --grep "should split lines"

Combine with --run to filter tests within a specific file:

./scripts/test.sh --run src/vs/editor/test/common/model.test.ts --grep "should split lines"

--runGlob <pattern> (aliases: --glob, --runGrep) - Run tests matching a glob

Runs all test files matching a glob pattern against the compiled output directory. Useful for running all tests under a feature area.

./scripts/test.sh --runGlob "**/editor/test/**/*.test.js"

Note: the glob runs against compiled .js files in the output directory, not source .ts files.

--coverage - Generate a coverage report

./scripts/test.sh --run src/vs/editor/test/common/model.test.ts --coverage

--timeout <ms> - Set test timeout

Override the default Mocha timeout for long-running tests.

./scripts/test.sh --run src/vs/editor/test/common/model.test.ts --timeout 10000

Integration tests

Integration tests (files ending in .integrationTest.ts or located in extensions/) are not run by scripts/test.sh. Use scripts/test-integration.sh (or scripts/test-integration.bat) instead. See the integration-tests skill for details.

Compilation requirement

Tests run against compiled JavaScript output. Ensure the VS Code - Build watch task is running or that compilation has completed before running tests. Test failures caused by stale output are a common pitfall.

Frequently asked questions about Unit Tests

Similar skills