Skip to content

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

Open
@unional

Description

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

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions