You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running vitest with --coverage using Storybook Test plugin, the reports include story files, which is not expected and affects coverage calculations:
The solution is rather simple but has to be done in user land. You can fix it by adding this config to your main vitest (or vite) config:
// vitest.config.tsimport{defineConfig,coverageConfigDefaults}from'vitest/config'exportdefaultdefineConfig({// ... rest of your configtest: {coverage: {exclude: [
...coverageConfigDefaults.exclude,'**/*.stories.*'// or whatever else the users use, e.g. '**/*.story.*' or '**/stories.*'],}}})
This change can't be added in a workspace file because workspaces can't define test.coverage options. Because of that, and the fact that Storybook Test plugin is set up at the workspace level, it makes it impossible for us to set up this configuration automatically as part of the plugin.
Potential solutions for us:
Document this limitation and explain how to solve it
When executing the postinstall script of addon test, automatically configure the vite configuration file to include coverage exclude options
If we don't automatically do it, at least point a link to the docs in the postinstall script
Additionally, we could provide our own export with coverage defaults like so, to make it easier (?) for users:
// vitest.config.tsimport{defineConfig}from'vitest/config'import{coverageConfigDefaults}from'@storybook/experimental-addon-test/config'exportdefaultdefineConfig({// ... rest of your configtest: {coverage: {exclude: [
...coverageConfigDefaults.exclude,// should include vitest defaults + Storybook defaults// Storybook defaults would be '**/*.stories.*', '**/*.story.*', '**/stories.*', '**/story.*'],}}})
The text was updated successfully, but these errors were encountered:
Describe the bug
When running vitest with --coverage using Storybook Test plugin, the reports include story files, which is not expected and affects coverage calculations:
The solution is rather simple but has to be done in user land. You can fix it by adding this config to your main vitest (or vite) config:
This change can't be added in a workspace file because workspaces can't define test.coverage options. Because of that, and the fact that Storybook Test plugin is set up at the workspace level, it makes it impossible for us to set up this configuration automatically as part of the plugin.
Potential solutions for us:
Additionally, we could provide our own export with coverage defaults like so, to make it easier (?) for users:
The text was updated successfully, but these errors were encountered: