addon-coverage icon indicating copy to clipboard operation
addon-coverage copied to clipboard

[Bug]: The code in this story is not instrumented on excluded stories

Open unional opened this issue 11 months ago • 1 comments

Describe the bug

I have some stories I want to exclude from coverage. So I have this config:

const config = {
  addons: [{
    name: '@storybook/addon-coverage',
    options: {
      istanbul: {
        exclude: ["**/Button*"]  // <-- here
      }
    }
  }]
}

When running test-storybook --coverage, those stories failed with:

    [Test runner] An error occurred when evaluating code coverage:
      The code in this story is not instrumented, which means the coverage setup is likely not correct.
      More info: https://github.com/storybookjs/test-runner#setting-up-code-coverage

Steps to reproduce the behavior

https://github.com/cyberuni/storybook-coverage-instrument-issue

pnpm i
pnpm storybook
pnpm test-storybook --coverage # another terminal

Expected behavior

Those stories should be excluded from the coverage and should not fail.

Screenshots and/or logs

image

Environment

  • OS: Windows 11
  • Node.js version: v18.12.1
  • PNPM version: 7.18.0

Additional context

unional avatar Aug 08 '23 03:08 unional