Best use case
test-infrastructure is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. When invoked:
When invoked:
Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.
Practical example
Example input
Use the "test-infrastructure" skill to help with this workflow task. Context: When invoked:
Example output
A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.
When to use this skill
- Use this skill when you want a reusable workflow rather than writing the same prompt again and again.
When not to use this skill
- Do not use this when you only need a one-off answer and do not need a reusable workflow.
- Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/test-infrastructure/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How test-infrastructure Compares
| Feature / Agent | test-infrastructure | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
When invoked:
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Test Infrastructure Agent - Real Coverage Builder
**Purpose**: Creates and maintains comprehensive test coverage. No stubs, no fakes, no empty files.
**Core Principle**: Tests are executable specifications. If a test is empty, the feature is incomplete.
## Responsibilities
### 1. Test Inventory & Gap Analysis
When invoked:
```
ASSESS CURRENT STATE
├─ Count actual test lines (not file count)
├─ Identify stub/empty test files
├─ Find untested critical paths
├─ Measure real coverage (not percentage games)
└─ Create priority list for new tests
REPORT
├─ Tests with real coverage: X
├─ Empty test files: Y
├─ Critical gaps: Z
└─ Estimated work: T hours
```
### 2. Test Writing
**Standards**:
- Real tests, real assertions
- Tests actually run and verify behavior
- Tests catch real bugs (not theater)
- Coverage targets: critical paths first, then features
**Test Hierarchy** (in order of priority):
1. **Critical Path Tests** - Features that break revenue/core functionality
2. **Integration Tests** - API routes, database, auth flows
3. **Component Tests** - UI rendering, interaction
4. **Unit Tests** - Individual functions, logic
5. **Edge Case Tests** - Error handling, boundaries
### 3. Quality Gates
Every test must pass:
- Actually runs (not syntax errors)
- Actually asserts something (not just "does it crash?")
- Catches real bugs (break the code, test fails)
- Doesn't flake (passes consistently)
- Is maintainable (readable, clear intent)
## Workflow
### Phase 1: Audit
```typescript
// Step 1: Identify test files
Find all **/*.test.ts, **/*.test.tsx, **/*.spec.ts files
// Step 2: Categorize them
for each file {
lines = countRealTestCode(file) // exclude comments, setup
if (lines < 50) → STUB
if (lines < 200) → INCOMPLETE
if (lines >= 200) → HAS_COVERAGE
}
// Step 3: Identify gaps
missing = criticalPaths.filter(p => !hasTest(p))
```
### Phase 2: Priority Assessment
```
CRITICAL (write first)
├─ Authentication flow
├─ API auth + RLS enforcement
├─ Email processing
├─ Content generation
├─ Campaign execution
└─ Database operations
IMPORTANT (write next)
├─ UI rendering
├─ Form submission
├─ Navigation
├─ Error handling
└─ Edge cases
NICE-TO-HAVE (write if time)
├─ Performance
├─ Accessibility
└─ Analytics
```
### Phase 3: Test Writing
```
For each critical path:
1. UNDERSTAND THE FLOW
- What does this feature do?
- What are inputs/outputs?
- What can go wrong?
2. WRITE TEST CASES
- Happy path (normal operation)
- Sad paths (errors, edge cases)
- Boundary conditions
3. IMPLEMENT TESTS
- Use appropriate testing library
- Make assertions clear
- Avoid mocking unless necessary
4. RUN & VERIFY
- Test runs without errors
- Breaks when code breaks
- Clear failure messages
```
## Test Writing Guidelines
### Unit Tests (for functions/logic)
```typescript
describe('contactScoringEngine', () => {
// GOOD: Tests specific behavior
it('calculates score of 85 for high engagement contact', () => {
const contact = {
emailOpenRate: 0.8,
emailClickRate: 0.6,
sentiment: 'positive'
};
const score = scoreContact(contact);
expect(score).toBe(85);
});
// BAD: Doesn't assert anything meaningful
it('works', () => {
scoreContact({...});
});
// GOOD: Tests error case
it('returns 0 for contact with no engagement data', () => {
const contact = { emailOpenRate: 0, emailClickRate: 0 };
const score = scoreContact(contact);
expect(score).toBe(0);
});
});
```
### Integration Tests (for API routes + database)
```typescript
describe('POST /api/contacts', () => {
// GOOD: Tests full flow with database
it('creates contact and returns assigned ID', async () => {
const response = await fetch('/api/contacts', {
method: 'POST',
headers: { Authorization: 'Bearer token' },
body: JSON.stringify({
email: 'new@example.com',
name: 'Test User'
})
});
expect(response.status).toBe(201);
const data = await response.json();
expect(data.id).toBeDefined();
// Verify it was actually saved
const saved = await db.contacts.findById(data.id);
expect(saved.email).toBe('new@example.com');
});
// GOOD: Tests authorization
it('rejects request without valid auth token', async () => {
const response = await fetch('/api/contacts', {
method: 'POST',
body: JSON.stringify({ email: 'new@example.com' })
});
expect(response.status).toBe(401);
});
});
```
### Component Tests (for React)
```typescript
describe('HotLeadsPanel', () => {
// GOOD: Tests rendering and interaction
it('displays hot leads and allows filtering', async () => {
const { getByText, getByRole } = render(
<HotLeadsPanel leads={mockLeads} />
);
expect(getByText('Hot Leads')).toBeInTheDocument();
const filterBtn = getByRole('button', { name: /filter/i });
fireEvent.click(filterBtn);
expect(getByText('Filter options')).toBeInTheDocument();
});
// BAD: Just checks it renders without error
it('renders', () => {
render(<HotLeadsPanel leads={mockLeads} />);
});
});
```
## Test Coverage Targets
```
API Routes
├─ Auth routes: 100% (critical security)
├─ CRUD operations: 95% (core functionality)
├─ Integration routes: 80% (complex flows)
└─ Utility routes: 70% (less critical)
Services
├─ Email service: 100% (revenue critical)
├─ Agent logic: 95% (core feature)
├─ Database queries: 90% (data integrity)
└─ Utilities: 70%
Components
├─ Critical path components: 90%
├─ UI components: 70%
└─ Utilities: 50%
Overall: Target 75%+ real coverage
```
## Running Tests
```bash
# Run all tests
npm test
# Run specific suite
npm test -- auth
# Run with coverage report
npm run test:coverage
# Watch mode for development
npm test -- --watch
# Generate coverage report
npm run test:coverage -- --reporter=html
```
## Dealing with Untestable Code
**If something is hard to test, that's a design problem.**
Red flags:
- Needs to mock 5+ dependencies
- Tests require heavy fixtures
- Can't test without hitting database
- State is global or hidden
Solutions:
1. Refactor for testability
2. Extract logic to pure functions
3. Separate concerns (data access vs logic)
4. Use dependency injection
## Test Maintenance
```
Monthly tasks:
├─ Update tests when features change
├─ Remove obsolete tests
├─ Review test performance (slow tests?)
├─ Check coverage hasn't dropped
└─ Refactor duplicated test code
```
## Quality Metrics
Track these:
- Lines of actual test code (growing)
- Real coverage % (not inflated by stubs)
- Test execution time (should stay <5min)
- Test flakiness (0 flaky tests)
- Bugs caught before production (trending up)
## Success Criteria
✅ All critical paths have real tests
✅ Tests are fast (<5 seconds)
✅ Tests catch bugs (coverage > 75%)
✅ No empty test files
✅ All tests pass on main branch
✅ Coverage trend is increasing
## Anti-Patterns (What We Stop)
❌ Empty test files that "count" toward coverage
❌ Stub tests with no assertions
❌ Mocking the thing you're testing
❌ Tests that pass whether code works or not
❌ Copy-paste tests (unmaintainable)
❌ One giant test file (hard to find issues)
❌ Writing tests after code (finds nothing)
---
**Key Mantra**:
> "An empty test file is admitting we don't know if it works.
> Real tests are how we earn the right to claim features are done."Related Skills
testing-strategies
Design comprehensive testing strategies for software quality assurance. Use when planning test coverage, implementing test pyramids, or setting up testing infrastructure. Handles unit testing, integration testing, E2E testing, TDD, and testing best practices.
backend-testing
Write comprehensive backend tests including unit tests, integration tests, and API tests. Use when testing REST APIs, database operations, authentication flows, or business logic. Handles Jest, Pytest, Mocha, testing strategies, mocking, and test coverage.
qa-test-planner
Generate comprehensive test plans, manual test cases, regression test suites, and bug reports for QA engineers. Includes Figma MCP integration for design validation.
game-test-case-generator
基于需求文档(xls/csv)生成专业游戏测试用例,支持完整用例和快速测试点两种模式。当用户提到"游戏测试"、"测试用例生成"、"需求转测试用例"、上传需求文档或原型时使用此技能。
wordpress-penetration-testing
This skill should be used when the user asks to "pentest WordPress sites", "scan WordPress for vulnerabilities", "enumerate WordPress users, themes, or plugins", "exploit WordPress vulnerabilities", or "use WPScan". It provides comprehensive WordPress security assessment methodologies.
web3-testing
Test smart contracts comprehensively using Hardhat and Foundry with unit tests, integration tests, and mainnet forking. Use when testing Solidity contracts, setting up blockchain test suites, or validating DeFi protocols.
web-security-testing
Web application security testing workflow for OWASP Top 10 vulnerabilities including injection, XSS, authentication flaws, and access control issues.
unit-testing-test-generate
Generate comprehensive, maintainable unit tests across languages with strong coverage and edge case focus.
testing-qa
Comprehensive testing and QA workflow covering unit testing, integration testing, E2E testing, browser automation, and quality assurance.
test-fixing
Run tests and systematically fix all failing tests using smart error grouping. Use when user asks to fix failing tests, mentions test failures, runs test suite and failures occur, or requests to make tests pass.
test-automator
Master AI-powered test automation with modern frameworks, self-healing tests, and comprehensive quality engineering. Build scalable testing strategies with advanced CI/CD integration. Use PROACTIVELY for testing automation or quality assurance.
terraform-infrastructure
Terraform infrastructure as code workflow for provisioning cloud resources, creating reusable modules, and managing infrastructure at scale.