unit-tests

For running unit tests in the VS Code repository. Covers the runTests tool, scripts/test.sh (macOS/Linux) and scripts/test.bat (Windows), and the parameters those tools support for filtering, globbing, and debugging tests.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "unit-tests" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-81a7ca4cd40b0495c08e58384b7ee99fcfcdfcc282576a1b9b8af4993574e838. Verify the upstream source and version against https://skills.sh/microsoft/vscode/unit-tests before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skills.sh

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

For running unit tests in the VS Code repository. Covers the runTests tool, scripts/test.sh (macOS/Linux) and scripts/test.bat (Windows), and the parameters those tools support for filtering, globbing, and debugging tests.

0 Downloads

Introduction source: third_party · microsoft · 1.0.0 Reference

SkillPi interpretation

Tasks
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.
Software, accounts and paid services
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.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
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.

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.

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value95/100

Highlights

  • 提供 VS Code 仓库单元测试的完整解决方案,覆盖高频刚需场景
  • 区分 Preferred(runTests 工具)和 Fallback(shell 脚本)两种路径,实用性强
Trigger Precision95/100

Highlights

  • 触发描述精准限定于 VS Code 仓库单元测试场景,边界清晰
  • 覆盖 runTests 工具、test.sh/test.bat 脚本及常用参数,无歧义
Structure and Standards95/100

Highlights

  • 文档结构清晰,分场景说明,步骤明确
  • 包含多个端到端示例,frontmatter 完整,符合规范
Execution Reliability95/100

Highlights

  • 工具来源明确,参数说明准确
  • 覆盖编译要求、集成测试区分等重要异常场景,可靠性高
Evidence Verifiability (mean of the first four)95/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

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.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.