| name | testing-standards |
| description | Write comprehensive tests following TDD and best practices. Use when generating unit tests, integration tests, or end-to-end tests for any code |
Testing Standards Skill
Test Structure (AAA Pattern)
describe('Component/Function Name', () => {
it('should do something specific', () => {
const input = { foo: 'bar' }
const result = functionUnderTest(input)
expect(result).toEqual(expectedOutput)
})
})
Test Categories
Unit Tests
- Test single functions/methods
- Mock all dependencies
- Fast (<100ms per test)
- High coverage (80%+)
Integration Tests
- Test component interactions
- Use test database
- Moderate speed
- Focus on critical paths
E2E Tests
- Test complete user flows
- Use real browser
- Slower execution
- Test happy paths only
Best Practices
- Descriptive Names:
it('should return 401 when token is expired')
- One Assert Per Concept: Test one thing at a time
- Independent Tests: No shared state between tests
- Use Factories: Create test data with factories
- Mock External Services: APIs, databases, file system