From e3cf32299578beb2a1ae20249f0737aa97a4d553 Mon Sep 17 00:00:00 2001 From: jonniebigodes Date: Tue, 19 Dec 2023 20:10:10 +0000 Subject: [PATCH 1/2] Docs: Adds troubleshooting for test flag --- README.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cf746ae..aed2bfb 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ export default { | `debug` | Enables the debug mode, providing additional logging information during the instrumentation process. | `boolean` | - | > **Note:** -> If you're using typescript, you can import the type for the options like so: +> If you're using TypeScript, you can import the type for the options like so: > > ```ts > import type { AddonOptionsWebpack } from "@storybook/addon-coverage"; @@ -77,12 +77,42 @@ export default { | `nycrcPath ` | Path to specific nyc config to use instead of automatically searching for a nycconfig. This parameter is just passed down to @istanbuljs/load-nyc-config. | `string` | `-` | > **Note:** -> If you're using typescript, you can import the type for the options like so: +> If you're using TypeScript, you can import the type for the options like so: > > ```ts > import type { AddonOptionsVite } from "@storybook/addon-coverage"; > ``` + +## Troubleshooting + +### The coverage addon doesn't support optimized builds + +The `--test` flag is designed to be as fast as possible, removing addons known to slow down the build and are not needed for functional testing. One of these addons is `@storybook/addon-coverage`, which is used in conjunction with the Storybook Test runner to collect coverage information for your stories. + +If you are using `addon-coverage` **AND** running the test runner against your _built_ Storybook, the `--test` flag will strip out the coverage information. To configure the `--test` build to keep coverage information (at the expense of a slightly slower build), update your Storybook configuration file (i.e.,`.storybook/main.js|ts`) and include the [`disabledAddons`](https://storybook.js.org/docs/api/main-config-build#testdisabledaddons) option. + +```js +// main.js + +export default { + addons: [ + '@storybook/addon-links', + '@storybook/addon-essentials', + '@storybook/addon-interactions', + '@storybook/addon-coverage', + ], + build: { + test: { + disabledAddons: [ + '@storybook/addon-docs', + '@storybook/addon-essentials/docs', + ], + }, + }, +} +``` + ### Development scripts - `yarn start` runs babel in watch mode From 5d83d6856494e8371d0f24fc570b0878530b0d3a Mon Sep 17 00:00:00 2001 From: jonniebigodes Date: Fri, 22 Dec 2023 18:33:44 +0000 Subject: [PATCH 2/2] Fix snippet --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index aed2bfb..8ff8cb6 100644 --- a/README.md +++ b/README.md @@ -96,12 +96,7 @@ If you are using `addon-coverage` **AND** running the test runner against your _ // main.js export default { - addons: [ - '@storybook/addon-links', - '@storybook/addon-essentials', - '@storybook/addon-interactions', - '@storybook/addon-coverage', - ], + // Your Storybook configuration goes here build: { test: { disabledAddons: [