testing-strategy
23
总安装量
7
周安装量
#16228
全站排名
安装命令
npx skills add https://github.com/block/agent-skills --skill testing-strategy
Agent 安装分布
amp
5
opencode
5
kimi-cli
5
codex
5
gemini-cli
5
Skill 文档
Testing Guidelines
Unit Tests
- Test one thing per test
- Use descriptive test names:
test_user_creation_fails_with_invalid_email - Mock external dependencies
- Keep tests fast and isolated
Integration Tests
- Test API endpoints with realistic data
- Verify database state changes
- Clean up test data after each test
- Use test fixtures for common scenarios
Running Tests
# Run all tests
npm test
# Run unit tests only
npm test:unit
# Run integration tests (requires database)
npm test:integration
# Run tests with coverage
npm test:coverage
Test Structure
tests/
âââ unit/ # Fast, isolated unit tests
âââ integration/ # Tests requiring external services
âââ fixtures/ # Shared test data
âââ helpers/ # Test utilities
Best Practices
- Arrange-Act-Assert: Structure tests clearly
- One assertion per test: When possible, test one behavior
- Descriptive names: Test names should describe the scenario
- No test interdependence: Tests should run in any order
- Clean state: Each test starts with a known state
Coverage Goals
- Aim for 80%+ line coverage
- Focus on critical paths first
- Don’t sacrifice test quality for coverage numbers