storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.68k stars 9.32k forks source link

[Bug]: expect.toThrow does not work #28406

Open kasperpeulen opened 4 months ago

kasperpeulen commented 4 months ago

Describe the bug

Getting this error when calling expect.toThrow()

export const LoggedIn: Story = {
  play: async ({ canvasElement }) => {
    await expect(() => {
      throw new Error('throw');
    }).toThrowError();
  },
};
Caught exception in play function
TypeError: Cannot redefine property: not
    at Function.defineProperty (<anonymous>)
    at https://kkvilmnmwpgithub-soxc--6006--70dbe416.local-credentialless.webcontainer.io/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-ICANM5TM.js?v=455c4f60:1577:23
    at Array.reduce (<anonymous>)
    at Instrumenter.instrument (https://kkvilmnmwpgithub-soxc--6006--70dbe416.local-credentialless.webcontainer.io/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-ICANM5TM.js?v=455c4f60:1570:29)
    at Instrumenter.track (https://kkvilmnmwpgithub-soxc--6006--70dbe416.local-credentialless.webcontainer.io/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-ICANM5TM.js?v=455c4f60:1588:17)
    at Proxy.toThrowError (https://kkvilmnmwpgithub-soxc--6006--70dbe416.local-credentialless.webcontainer.io/node_modules/.cache/storybook/1c3385a5d25e538d10b518b310c74d3ca2690b6aaffeadccd74da79736171f86/sb-vite/deps/chunk-ICANM5TM.js?v=455c4f60:1580:262)
    at play (https://kkvilmnmwpgithub-soxc--6006--70dbe416.local-credentialless.webcontainer.io/src/stories/Page.stories.ts:23:8)
    at playFunction (https://kkvilmnmwpgithub-soxc--6006--70dbe416.local-credentialless.webcontainer.io/sb-preview/runtime.js:113:6184)
    at https://kkvilmnmwpgithub-soxc--6006--70dbe416.local-credentialless.webcontainer.io/sb-preview/runtime.js:149:3903
    at StoryRender.runPhase (https://kkvilmnmwpgithub-soxc--6006--70dbe416.local-credentialless.webcontainer.io/sb-preview/runtime.js:149:943)

Reproduction link

https://stackblitz.com/edit/github-qlgvbq?file=src%2Fstories%2FPage.stories.ts

Reproduction steps

No response

System

torybook Environment Info:

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm <----- active
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @storybook/addon-essentials: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/addon-interactions: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/addon-links: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/addon-onboarding: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/blocks: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/react: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/react-vite: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    @storybook/test: ^8.2.0-alpha.10 => 8.2.0-alpha.10 
    storybook: ^8.2.0-alpha.10 => 8.2.0-alpha.10

Additional context

No response

unional commented 2 weeks ago

Facing the same issue: https://github.com/repobuddy/storybook-addon-vis/tree/reject