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

More: all Testing rules · all GitHub Copilot rules

Related rules

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

Generate tests prompt file (Copilot)

A Copilot prompt file (/generate-tests) that writes focused unit tests for the selected code using the repo framework.

GitHub CopilotTesting

Jest testing rules

Cursor rules for Jest 30 test suites in TypeScript: structure, mocking boundaries, timers, and async tests.

CursorTesting

Playwright end-to-end testing rules

Cursor rules for Playwright Test (TypeScript): resilient locators, web-first assertions, fixtures, and no flaky waits.

CursorTesting

pytest testing CLAUDE.md

CLAUDE.md for Python test suites with pytest 8: fixtures, parametrize, mocking boundaries, and coverage.

Claude Code (CLAUDE.md)Testing

Test runner subagent (Claude Code)

A Claude Code subagent that runs the right tests for a change, diagnoses failures, and proposes minimal fixes.

Claude Code (CLAUDE.md)Testing

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.