| version | 1.0.0 |
| name | test-runner |
| description | Execute tests, analyze results, and diagnose failures across any testing framework. Use when running test suites, debugging failing tests, or configuring CI/CD testing pipelines.
|
| category | quality |
| allowed-tools | Read Write Edit Glob Grep Bash |
| license | MIT |
Test Runner Skill
Execute tests, analyze results, and diagnose failures across any testing framework.
When to Use
- Running test suites (unit, integration, E2E)
- Debugging failing tests
- Configuring CI/CD testing pipelines
- Adding new test coverage
- Performance testing
Supported Frameworks
| Language | Frameworks |
|---|
| JavaScript/TypeScript | Vitest, Jest, Playwright, Mocha |
| Python | pytest, unittest |
| Rust | cargo test |
| Go | go test |
Test Execution Patterns
Quick Test Run
npm test
npm test -- src/api/auth.test.ts
npm test -- --grep "auth"
npm test -- --watch
CI/CD Test Run
npm test -- --coverage
npm test -- --json > test-results.json
Debugging Failing Tests
npm test -- --verbose
npm test -- --testNamePattern="exact test name"
node --inspect-brk node_modules/.bin/vitest run
Result Analysis
Interpreting Test Output
PASS src/api/auth.test.ts (5.2 s)
✓ should authenticate valid user (3 ms)
✓ should reject invalid credentials (2 ms)
✕ should handle rate limiting (10 ms)
FAIL src/api/payment.test.ts (3.1 s)
✕ should process payment (20 ms)
expect(received).toBe(expected)
Expected: "completed"
Received: "pending"
Common Failure Patterns
| Pattern | Likely Cause | Solution |
|---|
| Timeout | Async not awaited | Add await or increase timeout |
| Null reference | Mock not provided | Add mock to test setup |
| Snapshot mismatch | UI changed | Update snapshot or fix implementation |
| Flaky test | Race condition | Add wait or fix timing issue |
Test Organization
AAA Pattern
describe('Authentication', () => {
it('should authenticate valid user', () => {
const credentials = { email: 'test@example.com', password: 'password123' };
const result = authService.login(credentials);
expect(result).toBeTruthy();
expect(result.token).toBeDefined();
});
});
Mock Strategies
Common Mocks
jest.mock('../services/external-api');
process.env.NODE_ENV = 'test';
jest.mock('fs', () => ({
readFileSync: jest.fn(),
}));
jest.useFakeTimers();
Coverage Analysis
Interpreting Coverage Reports
| Metric | Target | Meaning |
|---|
| Line | 80%+ | Code lines executed |
| Branch | 75%+ | Conditional paths taken |
| Function | 80%+ | Functions called |
Improving Coverage
- Identify gaps - Review uncovered lines
- Add edge cases - Test error paths
- Mock wisely - Don't over-mock real logic
CI/CD Integration
GitHub Actions
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: npm test -- --coverage
- name: Upload coverage
uses: codecov/codecov-action@v4
Quality Gates
npm test -- --coverage --coverageThreshold='{"global":{"branches":80}}'
npm test -- --bail
d.o.EPUB Studio Specific
Test Suites
| Suite | Command | Purpose |
|---|
| Unit | npm run test:unit | Component logic |
| Integration | npm run test:integration | API/DB integration |
| E2E | npm run test:e2e | Full user flows |
Required Test Coverage
Debugging Tips
When Tests Fail
- Read the error - Don't scan, read fully
- Check the stack trace - Find your code
- Reproduce locally - Run single test
- Check test isolation - Are tests independent?
- Verify mocks - Are mocks accurate?
Common Issues
| Issue | Fix |
|---|
| "Cannot find module" | Check path, install dependencies |
| "Async callback not called" | Add done() or return promise |
| "Expected X, got Y" | Check mock implementation |
Integration
- testing-strategy: Design test approach
- testdata-builders: Create test fixtures
- cicd-pipeline: CI/CD test configuration
Quality Checklist
Summary
Effective test execution requires understanding frameworks, analyzing failures, and integrating with CI/CD.