storybookjs / addon-coverage

MIT License
21 stars 10 forks source link

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

Open unional opened 1 year ago

unional commented 1 year ago

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

Additional context

OmarioHassan commented 9 months ago

Is there anyone still alive here

chortis commented 3 months ago

Is there anyone still alive here

Old, but the way I got around this was to use --excludeTags (or --includeTags) and add tags to what is not covered. The tests will skip (this was fine in our case), but to get around that you could do a separate run without the coverage flag on those tests and use --includeTags.

I agree it sucks though, it should still run the tests with a possible warning