Home › Testing › Test files Copilot path instructions

Test files Copilot path instructions

Path-specific Copilot instructions applied to test files in any language: structure, determinism, and no cheating.

GitHub CopilotTesting

How to use

Save this as .github/instructions/tests.instructions.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

.github/instructions/tests.instructions.mdDownload  
---
applyTo: "**/*.test.*,**/*.spec.*,**/test_*.py,**/*_test.go,tests/**"
description: How to write and change tests
---

# Test files

## Structure
- One behavior per test; name it as a sentence ("returns 404 when the order is missing").
- Arrange / act / assert with a blank line between sections.
- Use table-driven or parametrized tests for input variations instead of copy-paste.
- Build test data with small factories/builders; only set the fields that matter to the test.

## Determinism
- No real network, wall-clock time, or unseeded randomness. Fake the clock, seed RNGs, stub HTTP at the boundary.
- Tests must pass in any order and in parallel; clean up files, env vars, and DB rows.
- No fixed sleeps; wait on a condition or use fake timers.

## What to assert
- Assert on observable behavior (return values, HTTP responses, rendered text, DB state), not private internals or call counts unless the call is the behavior.
- Each test has at least one meaningful assertion; avoid giant snapshots.

## Never
- Never delete, skip, or loosen a failing test to make CI green, or change expected values to whatever the code returns now. If you believe the test is wrong, explain why in the PR.
- Never commit focused tests (`.only`, `fit`, `-run` hacks).

Related rules

Angular 20 Copilot instructions

Copilot instructions for Angular 20 apps using standalone components, signals, and the new control flow.

GitHub CopilotAngular

Code review Copilot instructions

Copilot instructions focused on pull request review: what to flag, severity labels, and how to word comments.

GitHub CopilotAgent workflows

C# / .NET Copilot path instructions

Path-specific Copilot instructions for C# files on .NET 10: nullable types, async, records, and logging.

GitHub Copilot.NET / ASP.NET Core

Cypress end-to-end testing AGENTS.md

AGENTS.md for Cypress 15 E2E and component tests: selectors, cy.intercept, sessions, and flake-free waits.

AGENTS.mdTesting

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.