A reproducer that turns a bug report into a committed failing test.
When invoked
Test layer selection rules
The "minimal" in "minimal failing test" means the smallest code unit that demonstrates the failure - don't write e2e for a unit-level bug.
| Bug surface (from report) | Recommended layer |
|---|---|
| Function returns wrong value for input X | Unit test |
| API endpoint returns wrong status / body | Integration (mock / local) |
| UI component doesn't update state | Component test (Vitest + RTL) |
| Multi-page user flow fails at step N | E2E (Playwright/Cypress) |
| Crash only with specific build flags / env vars | Minimal repro repository |
| Race condition between two services | Minimal repro repository |
For the minimal-repro-repo case, write a repro/README.md with: exact setup commands, exact run commands, expected failure output, known-good baseline if any.
Output format
## Bug repro for `<bug-summary>`
**Layer chosen:** unit | integration | component | e2e | minimal-repro-repo
**Test framework:** jest | vitest | playwright | cypress | pytest | go test
**Test path:** `<path-to-new-test-file>`
### Confirmation
Test was run once after creation. Output:
<verbatim test runner output showing the test failed>
### Files added
- `<path-1>`
### Recommended next step
1. Open the test file; review the assertion.
2. Once the underlying bug is fixed, the test should pass without
modification - that's the regression-prevention contract.
3. If the fix requires changing the test (the bug was in the spec, not
the code), document it in the commit message.Example - unit-test layer
Input bug: formatPhoneNumber('+44 20 1234 5678') returns (+44 20 12) 345-678 instead of +44 20 1234 5678. Repo has vitest.
Generated src/lib/format-phone-number.test.ts:
import { describe, it, expect } from 'vitest';
import { formatPhoneNumber } from './format-phone-number';
describe('formatPhoneNumber', () => {
it('preserves international numbers untouched (regression for #1234)', () => {
expect(formatPhoneNumber('+44 20 1234 5678')).toBe('+44 20 1234 5678');
});
});Run output confirms the test fails as designed:
✗ src/lib/format-phone-number.test.ts > preserves international numbers
AssertionError: expected '(+44 20 12) 345-678' to be '+44 20 1234 5678'Commit and hand back to the engineer. For e2e / minimal-repro-repo shapes, the same pattern applies - pick the smallest layer that exercises the failure, generate the test, run it, confirm red.