| description | Instructions for the Copilot coding agent when working on test-coverage issues. |
|---|---|
| applyTo | test/unit-tests/**/*.ts,src/**/*.ts |
You are improving test coverage for microsoft/vscode-cmake-tools.
This file contains mandatory protocol. Read all of it before writing code.
- Read every source file you will test in full
- Read existing tests for that module (if any) in
test/unit-tests/backend/ - Identify every exported function, class, and branch condition
- Do not write tests for private implementation details — test the public API
- If a source file deeply depends on
vscodeAPIs, skip it — note in the PR that it needs integration-test coverage
Every test must:
- Have a descriptive name:
'expandString handles undefined variable in preset context' - Assert exactly one logical behavior per
test()block - Not depend on side effects from another test
- Use
assert.strictEqual/assert.deepStrictEqualover loose equality - For async code:
awaitand assert the resolved value — never.then()
# 1. Type-check test files
npx tsc -p test.tsconfig.json --noEmit
# 2. Lint
yarn lint
# 3. Run backend tests (this is the primary validation step)
yarn backendTests
# 4. Confirm coverage improved for the specific file
npx c8 --all --reporter=text --src=src \
node ./node_modules/mocha/bin/_mocha \
-u tdd --timeout 999999 --colors \
-r ts-node/register \
-r tsconfig-paths/register \
"./test/unit-tests/backend/**/*.test.ts"All steps must pass. If any fail, fix the failures before opening the PR.
Note:
yarn unitTestsrequires a VS Code extension host and a display server. It cannot be run in headless agent environments. The CI workflow validates those separately — you only need to runyarn backendTestsandyarn lintlocally.
Do not open the PR unless every file listed in the issue has either:
- improved by ≥ 10 percentage points from the baseline in the issue, OR
- reached ≥ 60% line coverage
| Rule | Why |
|---|---|
Test both useCMakePresets branches where the source branches on it |
Most bugs affect only one mode |
| Test both single-config and multi-config generator paths where relevant | CMAKE_BUILD_TYPE vs --config are frequent bug sources |
For src/expand.ts changes: test every macro type |
copilot-instructions.md explicitly mandates this |
For src/diagnostics/: test each compiler family's parser |
diagnostics.test.ts is the largest test file — keep it comprehensive |
Use @cmt/ path alias for imports from src/ |
Never use relative paths from outside src/ |
Never use console.log in test files |
Use the module logger or plain assert |
- Branch name:
coverage/<module-name>-tests - Open as ready for review only after the self-audit checklist in the issue is fully checked
- PR description must use the coverage template: copy the contents of
.github/PULL_REQUEST_TEMPLATE/coverage.mdinto the PR body (or append?template=coverage.mdto the PR creation URL). Fill in the coverage-delta table and check every self-audit box. CHANGELOG.mdmust have one entry underImprovements: