diff --git a/docs/writing-tests/test-coverage.md b/docs/writing-tests/test-coverage.md index 69852844e173..680f5b18089a 100644 --- a/docs/writing-tests/test-coverage.md +++ b/docs/writing-tests/test-coverage.md @@ -12,7 +12,7 @@ Coverage tests examine the instrumented code against a set of industry-accepted ## Code instrumentation with the coverage addon -Storybook provides an official [test coverage addon](https://storybook.js.org/addons/@storybook/addon-coverage). Powered by [Instanbul](https://istanbul.js.org/), which allows out-of-the-box code instrumentation for the most commonly used frameworks and builders in the JavaScript ecosystem. +Storybook provides an official [test coverage addon](https://storybook.js.org/addons/@storybook/addon-coverage). Powered by [Istanbul](https://istanbul.js.org/), which allows out-of-the-box code instrumentation for the most commonly used frameworks and builders in the JavaScript ecosystem. ### Set up the coverage addon @@ -90,22 +90,22 @@ By default, the [`@storybook/addon-coverage`](https://storybook.js.org/addons/@s -| Option | Description | Plugin | -| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| `cwd` | Defines the current working directory
`options: { instanbul: { cwd: process.cwd(),}}` | Babel, Vite | -| `include` | Select the files to collect coverage
`options: { instanbul: { include: ['**/stories/**'],}}` | Babel, Vite | -| `exclude` | Select the files to exclude from coverage
`options: { instanbul: { exclude: ['**/stories/**'],}}` | Babel, Vite | -| `extension` | Sets additional file extensions for coverage
`options: { instanbul: { extension: ['.js', '.cjs', '.mjs'],}}` | Babel, Vite | -| `nycrcPath` | Defines the relative path for the existing nyc configuration file
`options: { instanbul: { nycrcPath: '../nyc.config.js',}}` | Babel, Vite | -| `excludeNodeModules` | Disables `node_modules` directory introspection
`options: { instanbul: { excludeNodeModules:false,}}` | Babel | -| `ignoreClassMethods` | Configures a set of method names to ignore from being collected
`options: { instanbul: { ignoreClassMethods: ['example', 'myMethod'],}}` | Babel | -| `useInlineSourceMaps` | Enables coverage collection on source maps
`options: { instanbul: { useInlineSourceMaps: false,}}` | Babel | -| `inputSourceMap` | Sets the value to store the source map.
Useful for instrumenting code programmatically
`options: { instanbul: { inputSourceMap: sourceMap,}}` | Babel | -| `onCover` | Hook to monitor coverage collection for all tests
`options: { instanbul: { onCover: (fileName, fileCoverage) => {},}}` | Babel | -| `requireEnv` | Overrides the `VITE_COVERAGE` environment variable's value by granting access to the `env` variables
`options: { instanbul: { requireEnv: true,}}` | Vite | -| `cypress` | Replaces the `VITE_COVERAGE` environment variable with `CYPRESS_COVERAGE`.
Requires Cypress
`options: { instanbul: { cypress: true,}}` | Vite | -| `checkProd` | Configures the plugin to skip instrumentation in production environments
`options: { instanbul: { checkProd: true,}}` | Vite | -| `forceBuildInstrument` | Configures the plugin to add instrumentation in build mode
`options: { instanbul: { forceBuildInstrument: true,}}` | Vite | +| Option | Description | Plugin | +| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | +| `cwd` | Defines the current working directory
`options: { istanbul: { cwd: process.cwd(),}}` | Babel, Vite | +| `include` | Select the files to collect coverage
`options: { istanbul: { include: ['**/stories/**'],}}` | Babel, Vite | +| `exclude` | Select the files to exclude from coverage
`options: { istanbul: { exclude: ['**/stories/**'],}}` | Babel, Vite | +| `extension` | Sets additional file extensions for coverage
`options: { istanbul: { extension: ['.js', '.cjs', '.mjs'],}}` | Babel, Vite | +| `nycrcPath` | Defines the relative path for the existing nyc configuration file
`options: { istanbul: { nycrcPath: '../nyc.config.js',}}` | Babel, Vite | +| `excludeNodeModules` | Disables `node_modules` directory introspection
`options: { istanbul: { excludeNodeModules:false,}}` | Babel | +| `ignoreClassMethods` | Configures a set of method names to ignore from being collected
`options: { istanbul: { ignoreClassMethods: ['example', 'myMethod'],}}` | Babel | +| `useInlineSourceMaps` | Enables coverage collection on source maps
`options: { istanbul: { useInlineSourceMaps: false,}}` | Babel | +| `inputSourceMap` | Sets the value to store the source map.
Useful for instrumenting code programmatically
`options: { istanbul: { inputSourceMap: sourceMap,}}` | Babel | +| `onCover` | Hook to monitor coverage collection for all tests
`options: { istanbul: { onCover: (fileName, fileCoverage) => {},}}` | Babel | +| `requireEnv` | Overrides the `VITE_COVERAGE` environment variable's value by granting access to the `env` variables
`options: { istanbul: { requireEnv: true,}}` | Vite | +| `cypress` | Replaces the `VITE_COVERAGE` environment variable with `CYPRESS_COVERAGE`.
Requires Cypress
`options: { istanbul: { cypress: true,}}` | Vite | +| `checkProd` | Configures the plugin to skip instrumentation in production environments
`options: { istanbul: { checkProd: true,}}` | Vite | +| `forceBuildInstrument` | Configures the plugin to add instrumentation in build mode
`options: { istanbul: { forceBuildInstrument: true,}}` | Vite | ## What about other coverage reporting tools?