test-infrastructure

When invoked:

25 stars

Best use case

test-infrastructure is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

When invoked:

Teams using test-infrastructure should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/test-infrastructure/SKILL.md --create-dirs "https://raw.githubusercontent.com/ComeOnOliver/skillshub/main/skills/aiskillstore/marketplace/cleanexpo/test-infrastructure/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/test-infrastructure/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How test-infrastructure Compares

Feature / Agenttest-infrastructureStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/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

vitest-test-creator

25
from ComeOnOliver/skillshub

Vitest Test Creator - Auto-activating skill for Test Automation. Triggers on: vitest test creator, vitest test creator Part of the Test Automation skill category.

performing-visual-regression-testing

25
from ComeOnOliver/skillshub

This skill enables Claude to execute visual regression tests using tools like Percy, Chromatic, and BackstopJS. It captures screenshots, compares them against baselines, and analyzes visual differences to identify unintended UI changes. Use this skill when the user requests visual testing, UI change verification, or regression testing for a web application or component. Trigger phrases include "visual test," "UI regression," "check visual changes," or "/visual-test".

generating-unit-tests

25
from ComeOnOliver/skillshub

This skill enables Claude to automatically generate comprehensive unit tests from source code. It is triggered when the user requests unit tests, test cases, or test suites for specific files or code snippets. The skill supports multiple testing frameworks including Jest, pytest, JUnit, and others, intelligently detecting the appropriate framework or using one specified by the user. Use this skill when the user asks to "generate tests", "create unit tests", or uses the shortcut "gut" followed by a file path.

train-test-splitter

25
from ComeOnOliver/skillshub

Train Test Splitter - Auto-activating skill for ML Training. Triggers on: train test splitter, train test splitter Part of the ML Training skill category.

test-retry-config

25
from ComeOnOliver/skillshub

Test Retry Config - Auto-activating skill for Test Automation. Triggers on: test retry config, test retry config Part of the Test Automation skill category.

generating-test-reports

25
from ComeOnOliver/skillshub

This skill generates comprehensive test reports with coverage metrics, trends, and stakeholder-friendly formats (HTML, PDF, JSON). It aggregates test results from various frameworks, calculates key metrics (coverage, pass rate, duration), and performs trend analysis. Use this skill when the user requests a test report, coverage analysis, failure analysis, or historical comparisons of test runs. Trigger terms include "test report", "coverage report", "testing trends", "failure analysis", and "historical test data".

test-parallelizer

25
from ComeOnOliver/skillshub

Test Parallelizer - Auto-activating skill for Test Automation. Triggers on: test parallelizer, test parallelizer Part of the Test Automation skill category.

test-organization-helper

25
from ComeOnOliver/skillshub

Test Organization Helper - Auto-activating skill for Test Automation. Triggers on: test organization helper, test organization helper Part of the Test Automation skill category.

test-naming-enforcer

25
from ComeOnOliver/skillshub

Test Naming Enforcer - Auto-activating skill for Test Automation. Triggers on: test naming enforcer, test naming enforcer Part of the Test Automation skill category.

managing-test-environments

25
from ComeOnOliver/skillshub

This skill enables Claude to manage isolated test environments using Docker Compose, Testcontainers, and environment variables. It is used to create consistent, reproducible testing environments for software projects. Claude should use this skill when the user needs to set up a test environment with specific configurations, manage Docker Compose files for test infrastructure, set up programmatic container management with Testcontainers, manage environment variables for tests, or ensure cleanup after tests. Trigger terms include "test environment", "docker compose", "testcontainers", "environment variables", "isolated environment", "env-setup", and "test setup".

generating-test-doubles

25
from ComeOnOliver/skillshub

This skill uses the test-doubles-generator plugin to automatically create mocks, stubs, spies, and fakes for unit testing. It analyzes dependencies in the code and generates appropriate test doubles based on the chosen testing framework, such as Jest, Sinon, or others. Use this skill when you need to generate test doubles, mocks, stubs, spies, or fakes to isolate units of code during testing. Trigger this skill by requesting test double generation or using the `/gen-doubles` or `/gd` command.

generating-test-data

25
from ComeOnOliver/skillshub

This skill enables Claude to generate realistic test data for software development. It uses the test-data-generator plugin to create users, products, orders, and custom schemas for comprehensive testing. Use this skill when you need to populate databases, simulate user behavior, or create fixtures for automated tests. Trigger phrases include "generate test data", "create fake users", "populate database", "generate product data", "create test orders", or "generate data based on schema". This skill is especially useful for populating testing environments or creating sample data for demonstrations.