-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
Add a Cursor rule (.cursor/rules/mdc-tdd-workflow.mdc) that enforces test-driven development whenever possible.
Rule details
The rule should mandate a Red-Green-Refactor cycle for all non-trivial changes:
- Red — write a small, focused test that fails.
- Green — write the minimum code to make it pass.
- Refactor — clean up without changing behavior; tests stay green.
When to apply TDD
- New functions, utilities, helpers
- Bug fixes (reproduce with a test first)
- API route handlers and data-processing logic
- Parsers, validators, transformation code
When TDD is impractical
- Pure layout/styling changes with no logic
- One-line config tweaks
- Temporary spikes (flagged as such)
Test quality guidelines
- One assertion per behavior; many small tests over few large ones
- Name tests as sentences:
it("returns 0 when the cart is empty") - Test inputs/outputs, not implementation details
- Mock external services; never hit real APIs in unit tests
- Keep test files next to source (
src/lib/foo.ts→src/lib/__tests__/foo.test.ts)
Acceptance criteria
-
.cursor/rules/mdc-tdd-workflow.mdcexists withalwaysApply: true - Rule documents the Red-Green-Refactor cycle with examples
- Rule lists when TDD applies and when it can be skipped
- Rule includes test quality guidelines
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels