storybookjs / test-runner

🚕 Turn stories into executable tests
https://storybook.js.org/docs/writing-tests/interaction-testing
MIT License
220 stars 66 forks source link

[Feature request]: Respect dangerouslyIgnoreUnhandledErrors #482

Closed IanVS closed 3 weeks ago

IanVS commented 1 month ago

Is your feature request related to a problem? Please describe.

I have a test that simulates a 500 error from the server, and shows that we handle it with an error boundary in our app. The story fails in the interaction test, however, so I added the suggested test.dangerouslyIgnoreUnhandledErrors parameter, which makes it green in the browser, but the test still fails in CI due to the test-runner seemingly not respecting it.

Describe the solution you'd like

Tests should not fail due to unhandled errors if dangerouslyIgnoreUnhandledErrors is set.

Describe alternatives you've considered

I can also disable the test and use a chromatic snapshot to validate that the correct screen is shown, which is what I'll do as a workaround for now.

Are you able to assist to bring the feature to reality?

yes, I can

Additional context

I marked yes i can above, but it's more of a "maybe". :-D

yannbf commented 3 weeks ago

Hey @IanVS as we spoke before, I was not able to reproduce this issue. The test-runner is not aware of that option because it doesn't have to, as it just listens to events from Storybook. So if your option is set, then Storybook should not emit the event to the test-runner

IanVS commented 3 weeks ago

Thanks for the reminder, I'll try to figure out what was happening.

IanVS commented 3 weeks ago

Sure enough, I can no longer reproduce the issue I was seeing before. I have a test that fails without dangerouslyIgnoreUnhandledErrors, both in test-runner and the UI, and it passes in both spots when I enable the flag. Something else must have been erroring before. Sorry for the false alarm!