Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Configuration options don't seem to get passed on to vitest #27010

Open
szpytfire opened this issue May 2, 2024 · 2 comments
Open

[Bug]: Configuration options don't seem to get passed on to vitest #27010

szpytfire opened this issue May 2, 2024 · 2 comments

Comments

@szpytfire
Copy link

szpytfire commented May 2, 2024

Describe the bug

A couple of my interaction tests are failing due to Unhandled Errors caused by an upstream dependency I'm using.

The output of the interaction test kindly suggests the following:

Unhandled Errors
Found 1 unhandled error while running the play function. This might cause false positive assertions. Resolve unhandled errors or ignore unhandled errors with setting the test.dangerouslyIgnoreUnhandledErrors parameter to true.

After reading this, I tried adding the following snippet into my .storybook/main.ts configuration:

  viteFinal: async (config, ...rest) => {
    const extraConfig = {
      test: {
        dangerouslyIgnoreUnhandledErrors: true,
      },
    };

    if (storybookConfig.viteFinal) {
      return mergeConfig(
        storybookConfig.viteFinal(config, ...rest),
        extraConfig,
      );
    }
    return mergeConfig(config, extraConfig);
  }

However, the exception is still thrown (and the interaction test still states that I need to set the test.dangerouslyIgnoreUnhandledErrors param).

Is this expected? Are parameters passed through to vitest?

To Reproduce

System

System:
    OS: macOS 14.2.1
    CPU: (8) arm64 Apple M2
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 4.1.0 - ~/.nvm/versions/node/v20.11.1/bin/yarn <----- active
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 8.3.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.94
    Safari: 17.2.1

Additional context

Relates to: xyflow/xyflow#2461

@szpytfire szpytfire changed the title [Bug]: Configuration options don seem to get passed on to vitest [Bug]: Configuration options don't seem to get passed on to vitest May 2, 2024
@jaknas
Copy link

jaknas commented May 7, 2024

@szpytfire You need to add it to your story parameters, see:

const ignoreUnhandledErrors =
this.story.parameters?.test?.dangerouslyIgnoreUnhandledErrors === true;

@szpytfire
Copy link
Author

Hey @jaknas - yep, thanks 🙏 I found this in the end after snooping around the storybook code 😄!

I wonder whether to help future users:

  • The error message should be updated slightly to make it more obvious that you have to set the param on the story
  • The dangerouslyIgnoreUnhandledErrors should be enabled at a global level (so that you don't have to set it on lots of individual stories)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants