testing-best-practices
Installation
SKILL.md
Testing Best Practices
Core Principle: Intention Over Implementation
Tests validate intentions, not implementations. The intention is what your code does for users; the implementation is how it achieves that.
// BAD: Testing implementation details
expect(cookieUtils.parse).toHaveBeenCalledWith('sessionId=abc-123', { pick: ['name'] })
// GOOD: Testing the intention
expect(parseCookieName('sessionId=abc-123')).toBe('sessionId')
The Golden Rule of Assertions
A test must fail if, and only if, the intention behind the system is not met.
Ask: "When will this test fail?" If it can fail for reasons unrelated to the intention, fix the test boundaries.