Skip to content
Skills Library
Programming · Testing

unit-tests

/unit-tests

Use when running unit tests in the VS Code repo. Covers the runTests tool, scripts/test.sh (macOS/Linux) and scripts/test.bat (Windows), and their supported arguments for filtering, globbing, and debugging tests.

Repository
vscode ↗
Licence
MIT
Last repository change
27.10.2026

Assessment and security

98/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene13 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when running unit tests in the VS Code repo. Covers the runTests tool, scripts/test.sh (macOS/Linux) and scripts/test.bat (Windows), and their supported arguments for filtering, globbing, and debugging tests.

Original author description

Use when running unit tests in the VS Code repo. Covers the runTests tool, scripts/test.sh (macOS/Linux) and scripts/test.bat (Windows), and their supported arguments for filtering, globbing, and debugging tests.

How it works

  1. Preferred: Use the runTests tool
  2. Fallback: Shell scripts
Original SKILL.md headings · 114 lines, 733 words
SKILL.md preview
---
name: unit-tests
description: Use when running unit tests in the VS Code repo. Covers the runTests tool, scripts/test.sh (macOS/Linux) and scripts/test.bat (Windows), and their supported arguments for filtering, globbing, and debugging tests.
---

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

The tool runs tests discovered by VS Code's registered test controllers; it does not compile the repository or invoke a shell test command. If discovery is unavailable, pending, or reports no executed tests, treat the request as unvalidated and use the repository's configured test command. Review per-file and test-name diagnostics for partially matched requests instead of repeatedly checking the same paths.

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.

```bash
./scripts/test.sh src/vs/editor/test/common/model.test.ts
```

```bat
.\scripts\test.bat src\vs\editor\test\common\model.test.ts
```

Multiple files:

```bash
./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.

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

Multiple files can be specified by repeating `--run`:

```bash
./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`).

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

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

```bash
./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.

```bash
./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

```bash
./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.

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

#### `--workers <count>` - Run all test files in parallel processes

Spreads a run of **all** test files across `<count>` worker processes. The count is required, and capped at one worker per CPU and per 2 GB of memory, because every worker loads all test files. Every worker loads all test files and runs the files it claims, in the usual order. It is ignored, and the run uses a single window or process, with `--run`, `--runList`, `--runGlob`, bare file paths, `--grep`, `--coverage` or `--dev`. With `--rerun-failed-files`, the failures of all workers are rerun in a single window or process. When a worker fails, the runner prints the test files it ran, in order, to pass to `--run` to reproduce the failure. `npm run test-node` and `npm run test-browser` accept it as well; the browser runner starts its own browser in every worker, runs the browsers one at a time, and ignores it with `--debug`.

```bash
./scripts/test.sh --workers 4
npm run test-node -- --workers 4
npm run test-browser -- --browser chromium --workers 4
```

### 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. Reuse current output from an existing `VS Code - Build` task when available; otherwise refresh client output with `npm run build-fast -- --client-only` before running tests. This supports cold and incremental builds without a persistent watcher or extension builds. Use `npm run build-fast` when extension and Copilot outputs are also needed. Fast builds transpile rather than type-check, so run appropriate explicit type checks when warranted by the change. Do not rebuild between test selections when inputs have not changed. Test failures caused by stale output are a common pitfall.

Versions

RepositoryScoreLicence
This page · microsoft/vscode98MIT
anomalyco/opencode100MIT
harlan-zw/harlan-claude-code100MIT
bklit/bklit-ui100MIT
thedaviddias/front-end-checklist100MIT
percival-de-galles/waypoint-ide98MIT

Identical content appears in 1 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version d7b25f6bda8e (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 98integration-tests
    Use when running integration tests in the VS Code repo. Covers scripts/test-integration.sh (macOS/Linux) and scripts/test-integration.bat (Windows), their supported arguments for filtering, and the difference between node.js integration tests and extension host tests.
  • 98integration-tests
    Use when running integration tests in the VS Code repo. Covers scripts/test-integration.sh (macOS/Linux) and scripts/test-integration.bat (Windows), their supported arguments for filtering, and the difference between node.js integration tests and extension host tests.
  • 100unit-testing
    Write and review unit tests for Gather V2. Use when writing tests, reviewing test code, debugging test failures, or asking about testing patterns.
  • 100run-c-unit-tests
    Run C/C++ unit tests to verify correctness. Use this after making changes to C code to verify nothing is broken.
  • 100write-tests
    Write or review unit tests for code in this repo. Use when writing new tests, reviewing existing tests, or adding test coverage.
  • 100v1-write-tests
    Use when writing unit tests for code changes or new functionality. Triggers on "write tests", "add tests", "test this code".

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.