CONTRIBUTOR-DOCS / Style guide / Testing guide / Code coverage
Coverage is collected by the Storybook Vitest project using the V8 provider.
We enforce per-path thresholds in vitest.config.js:
| Path pattern | Target | What it covers |
|---|---|---|
components/**/*.{ts,js} |
100% lines, functions, statements | SWC component implementations |
**/packages/core/components/**/*.{ts,js} |
100% lines, functions, statements | Core component base classes |
**/packages/core/shared/**/*.{ts,js} |
70% lines, functions, statements | Shared utilities |
Component code and base classes require 100% coverage. Shared utilities have a lower threshold that ratchets upward as coverage improves.
The coverage config uses autoUpdate with Math.floor to automatically lock in improvements:
thresholds: {
autoUpdate: (value) => Math.floor(value),
}When your tests push coverage above the current threshold, the config file updates itself. This prevents regressions without manual threshold bumps.
yarn workspace @adobe/swc test:coverageReview the generated report. If coverage drops below the threshold, add tests to cover the gap before merging.