# Coverage configuration is present

- **Pattern:** `ab-000306` (`ai-slop-test-theater.test-operability.coverage-config-present`)
- **Severity:** medium
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-000306
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-000306)

## Why it matters

Without a coverage configuration, you have no data on how much of your production code is actually exercised by tests. You may have 50 test files covering the same 3 utility functions while auth, billing, and error-handling code is entirely untouched. Coverage tooling in Vitest and Jest is built-in — it costs nothing to enable. Without it you cannot identify coverage gaps, set minimum thresholds to protect against regression, or demonstrate to auditors or SOC 2 reviewers that critical paths are tested. ISO-25010:2011 testability explicitly covers the ability to measure test completeness.

## Severity rationale

Medium because the absence of coverage config doesn't break existing tests but eliminates the feedback loop needed to catch growing blind spots in test coverage.

## Remediation

Enable coverage in `vitest.config.ts` or `jest.config.ts`. Set minimum thresholds that will fail CI if coverage drops below your baseline — start at 60% for lines, functions, branches, and statements:

```ts
// vitest.config.ts
export default defineConfig({
  test: {
    coverage: {
      provider: 'v8',
      reporter: ['text', 'html', 'json-summary'],
      thresholds: {
        lines: 60,
        functions: 60,
        branches: 60,
        statements: 60,
      },
      exclude: ['**/*.test.ts', '**/*.spec.ts', 'tests/**'],
    },
  },
})
```

Run `npx vitest run --coverage` to see the initial baseline before setting thresholds.

## Detection

- **ID:** `coverage-config-present`
- **Severity:** `medium`
- **What to look for:** Walk for coverage configuration: `vitest.config.ts` with `test.coverage`, `jest.config.{js,ts}` with `collectCoverage: true`, `nycrc`, `.c8rc`, `.nycrc`, OR a `coverage` script in `package.json`. Count all coverage configurations found.
- **Pass criteria:** At least 1 coverage configuration exists in either `vitest.config.ts`, `jest.config.{js,ts}`, `.nycrc`, `.c8rc`, OR a `coverage` script in `package.json`. Report: "Coverage config: [type] found in [file]."
- **Fail criteria:** Project has test files but no coverage configuration.
- **Skip (N/A) when:** Project has 0 test files.
- **Detail on fail:** `"Project has 47 test files but no coverage configuration. No way to know what percentage of production code is actually exercised by tests."`
- **Remediation:** Without coverage data, you don't know if your tests touch the critical paths. Enable coverage:

  ```ts
  // vitest.config.ts
  export default defineConfig({
    test: {
      coverage: {
        provider: 'v8',
        reporter: ['text', 'html', 'json'],
        thresholds: {
          lines: 60,
          functions: 60,
          branches: 60,
          statements: 60,
        },
      },
    },
  })
  ```

## External references

- iso-25010 maintainability.testability

Taxons: code-quality

HTML version: https://auditbuffet.com/patterns/ab-000306
