Skip to content

Coverage Criteria

20.4.1. Minimum Coverage

Projects must meet the following minimum coverage thresholds for TQS certification.

ItemMinimum ThresholdDescription
Lines80%Percentage of executed code lines
Branches70%Percentage of covered conditional branches (if/else, switch)
Functions80%Percentage of invoked functions
Statements80%Percentage of executed statements
  • New projects must write tests to meet the thresholds from the outset.
  • Existing projects should improve coverage incrementally; however, new code must meet the thresholds without exception.
  • Tests that merely invoke functions without meaningful assertions are not recognized, even if coverage numbers appear high.

20.4.2. Coverage Reports

Configure the coverage provider and report formats in vitest.config.ts.

typescript
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    coverage: {
      provider: 'v8',
      reporter: ['text', 'html', 'lcov'],
      reportsDirectory: './coverage',
      include: ['src/**/*.{ts,vue}'],
      exclude: [
        'src/**/*.d.ts',
        'src/**/*.test.ts',
        'src/**/*.spec.ts',
        'src/**/index.ts',
        'src/types/**',
        'src/constants/**',
        'src/auto-generated/**',
      ],
    },
  },
})
ProviderCharacteristics
v8Built-in V8 engine coverage, fast execution, Vitest default
istanbulPrecise instrumentation, broad ecosystem compatibility
Report FormatPurpose
textImmediate review in the terminal
htmlDetailed per-file coverage review in the browser
lcovIntegration with CI tools and external services (SonarQube, Codecov, etc.)
  • The TQS default coverage provider is v8.
  • Generating all three report formats (text, html, lcov) is recommended.

20.4.3. Exclusions

The following files are excluded from coverage measurement.

Exclusion TargetReason
Type definition files (*.d.ts)Not runtime code
Constant files (constants/)Value definitions with no logic
Auto-generated code (auto-generated/)Not manually maintained
Configuration files (vite.config.ts, vitest.config.ts, etc.)Build/test configuration only
Re-export files (index.ts)Perform only re-exports
Test files (*.test.ts, *.spec.ts)Test code itself is not a coverage target
  • Exclusion targets must be specified in the coverage.exclude array of vitest.config.ts.
  • When new exclusion targets are added, the configuration file must be updated through team consensus.

20.4.4. CI Integration

The CI pipeline must fail the build when coverage falls below the defined thresholds.

typescript
// vitest.config.ts
export default defineConfig({
  test: {
    coverage: {
      provider: 'v8',
      thresholds: {
        lines: 80,
        branches: 70,
        functions: 80,
        statements: 80,
      },
    },
  },
})

When thresholds are configured, Vitest returns a non-zero exit code if coverage falls below the specified values. The CI pipeline detects this and fails the build.

yaml
# CI pipeline example (GitHub Actions)
- name: Run tests with coverage
  run: yarn test:coverage

- name: Upload coverage report
  uses: actions/upload-artifact@v4
  with:
    name: coverage-report
    path: coverage/
  • The thresholds values must match the minimum coverage criteria defined in Section 20.4.1.
  • Coverage reports should be retained as CI artifacts to track history.
  • Integrating with external services (Codecov, SonarQube, etc.) to visualize coverage trends is recommended.

TIENIPIA QUALIFIED STANDARD