What this thread does
Do first: select the Copilot harness in VS Code, then identify the existing test runner, module command and uncovered error contract before editing.
Short answer
As of November 2026, this workflow uses VS Code 1.145. Keep the module real, arrange failures at its dependency boundary, and require a regression test that fails when the handler is deliberately broken.
Choose / don't choose
- Unit test: choose for malformed input, controlled rejections or timeouts whose behavior belongs to this module; don't call a live dependency to create a deterministic error.
- Integration/contract check: choose when the question is the real provider's error shape, adapter wiring or timeout behavior; don't infer that behavior from a mock (testing guide, mock boundary).
- Existing framework: choose the repository's runner; don't install a second one to accommodate generated code (GitHub guide).
Not for: Copilot cloud-agent dependency setup; see copilot-cloud-agent-setup-steps-preinstall-deps.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
.github/copilot-instructions.md | Record framework, exact command/directory, mocking convention and required error assertions | Current Copilot harness | instruction formats |
.github/instructions/**/*.instructions.md, applyTo | File-scoped instruction globs covering source and tests; ** covers all files; no default pattern | Current Copilot harness | scope |
chat.tools.terminal.autoApprove | true auto-approves a matched command; false requests review; allow only the intended local test command | Current VS Code approval docs | terminal rules |
chat.agent.sandbox.enabled | on; default off; inspect effective policy in a fresh session | Current Copilot sandbox | sandbox |
chat.agent.sandbox.network.allowNetwork | false for isolated unit tests; default true | Current Copilot sandbox | network |
chat.agent.sandbox.allowUnsandboxedCommands | false removes outside-sandbox fallback; default true | Current Copilot sandbox | fallback |
Use Manual permissions and review other tool/URL approvals. Terminal command rules are best-effort: the Copilot runtime can approve read-only or sandboxed commands before those rules. They do not enforce review of every dependency edit or network tool (approvals). Keep manifests unchanged during test generation and review their diff explicitly.
Order of operations
1. Run the existing focused suite; record prior failures. Attach the real module and one nearby test. Define the missing branch's required error/result, cleanup, and forbidden success effect. 2. Generate only the case and its dependency fixture. Demonstrate failure on the real defect; if behavior already passes, temporarily break the specific handler and require this case to fail, then restore it. This mutation check is an application review policy based on checking assertions, not a Copilot feature. 3. Reject a test that merely checks its own mock or derives its expectation from the production result. Return a promise from your test, and Jest will wait for that promise to resolve; prefer await expect(...).rejects..., or use expect.assertions(1) for catch-only assertions so unexpected fulfillment cannot pass (async completion). 4. After accepting the failing regression, repair production behavior as a separate reviewed change. Rerun the targeted case, existing success case, then the related suite. Check skipped counts, production diff and actual runner output (testing guide).
Known failures and fixes
| Error or symptom | Cause | Fix | Source |
|---|---|---|---|
| Test passes with broken handler (symptom) | Mock only the dependency; assert the public contract and required absence of effects | assertion review, Jest mocks | |
| Async rejection assertion never runs (symptom) | Omitting return/await lets the test complete before the promise resolves or rejects | Await/return the operation and rejection matcher; count expected catch assertions | Jest async |
| Agent reports pass, terminal shows failure (symptom) | Tool output reports success while the terminal shows failures | Inspect raw output and discovered/skipped counts | Tabberwocky, February 11, 2025, #4984 (closed December 8, 2025 as completed) |
In Test Explorer use Show Output and, when supported, Test: Show Inline Coverage (testing UI).
Additional references: Identify the testing setup, CLI's code --version, Testing → Test coverage, Review assertions and coverage, Run and debug tests.
Missing
- Coverage alone cannot show that an assertion catches a defect; the testing guide now explicitly confirms this.
- The older report includes agent-prepared material; it is a caution, not evidence of a current editor defect.
- No permission setting establishes mandatory review before every dependency change or external service call across all tools. Combine network isolation, tool permissions, bounded file scope and explicit diff review; do not claim terminal approval rules alone provide that gate.
- The module/framework/commands are project-specific. Jest examples apply only to repositories already using Jest.
Checked
2026-11-24; editor release, GitHub/VS Code testing guides, instruction/approval/sandbox references, Jest async/mock references, CLI reference and contributor report read. No editor agent or module tests executed.
Started from a post by @Microsoft, packaged by the editor. Original post