Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Update addon-test coverage exclude details #30059

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/writing-tests/test-coverage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Coverage is included in the Test addon and, when enabled, will be calculated whe

![Screenshot of test module, expanded, showing coverage toggle](../_assets/writing-tests/addon-test-module-edit-coverage.png)

Before coverage can be calculated, you may be prompted to install a support package corresponding to your [coverage provider](#coverage-provider):
Before coverage can be calculated, you may need to install a support package corresponding to your [coverage provider](#coverage-provider):


{/* prettier-ignore-start */}
Expand Down Expand Up @@ -192,7 +192,7 @@ When calculating coverage in the Storybook UI, the following options are always

#### Excluding stories from the coverage report

Until Vitest 2.2.0 is released, the generated coverage report will include the stories files themselves. This is misleading and they should be excluded. To do this, you can add the following to your Vitest config:
Until Vitest 3.0.0 is released, the generated coverage report will include the stories files themselves and output from your built Storybook application. This is misleading and they should be excluded. To do this, you can add the following to your Vitest config:

```ts title="vitest.config.ts"
import { coverageConfigDefaults, defineConfig } from 'vitest/config';
Expand All @@ -205,7 +205,9 @@ export default defineConfig({
exclude: [
...coverageConfigDefaults.exclude,
// This pattern must align with the `stories` property of your `.storybook/main.ts` config
'**/*.stories.*', '**/*.story.*', '**/stories.*', '**/story.*'
'**/*.stories.*',
// This pattern must align with the output directory of `storybook build`
'storybook-static/**',
],
Comment on lines +208 to 211
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding additional common story file patterns that were previously included: '/.story.', '/stories.', '**/story.'

}
}
Expand Down
Loading