test
Installation
SKILL.md
Essential Principles
Test what the code does, not what the mocks do.
- Real code over mocks. Mocks hide integration bugs and make tests brittle to refactoring — use real implementations. Mock only external services, non-deterministic inputs, or expensive I/O. If the function under test accepts a callback or dependency — pass a real one.
- Assert on behavior, not internals. Assert on return values, thrown errors, observable side effects. Never assert on call counts, internal state, or framework internals (e.g.,
setTimeoutspy). - One behavior per test. "and" in the test name → split it. Each test verifies one observable outcome.
- Names describe behavior. Test name = what the code does, stated as behavior. Good:
retries 3 times then throws the last error. Bad:respects maxAttempts. - No duplicate coverage. Two tests proving the same behavior = delete one. Each test must verify something no other test covers.
Quick Start
Before writing any test, ask:
- What observable behavior am I testing?
- Can I test this with real code instead of mocks?
- Does the test name describe what broke if it fails?
If any answer is unclear, return to ## Essential Principles before writing the test.