Skip to content

[Bug] Code outside of the yarn workspace are not instrumented #19

Open
@sw-tracker

Description

@sw-tracker

Describe the bug

I have 2 yarn workspaces, one containing my app and another containing storybook.

Steps to reproduce the behavior

  1. Setup react in one yarn workspace, create react components and stories here
  2. Setup a separate yarn workspace and install storybook there
  3. Set storybook main.js stories to be found in the react workspace
  4. Start storybook
  5. Run tests with coverage -> Error: The code in this story is not instrumented, which means the coverage setup is likely not correct.
// main.js
module.exports = {
  stories: [
    "../../components/src/**/*.stories.mdx",
    "../../components/src/**/*.stories.@(js|jsx|ts|tsx)",
  ],
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-interactions",
    '@storybook/addon-coverage',
  ],
  framework: "@storybook/react",
  features: {
    interactionsDebugger: true,
  },
}

I have also ejected storybook to get the tests to run:

// test-runner-jest.config.js
const {getJestConfig} = require('@storybook/test-runner');

module.exports = {
  // The default configuration comes from @storybook/test-runner
  ...getJestConfig(),
  /** Add your own overrides below
   * @see https://jestjs.io/docs/configuration
   */
  rootDir: '../components/',
  testEnvironmentOptions: {
    'jest-playwright': {
      browsers: ['chromium'],
    },
  },
};

Expected behavior

Tests with coverage work.

Screenshots and/or logs

Error:

 [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

Environment

  • OS: Windows
  • Node.js version: v14.21.1
  • NPM version: 6.14.17
  • Browser (if applicable): chrome (although storybook app isnt open)

Metadata

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