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

Fix StorybookTestRunnerError – length on undefined #194

Merged
merged 1 commit into from
Oct 7, 2022

Conversation

ericclemmons
Copy link
Contributor

@ericclemmons ericclemmons commented Sep 21, 2022

When running yarn test-storybook on my story, a 3rd party library throws an uncaught exception, but StorybookTestRunnerError assumes logs is an array, which throws this error:

UnhandledPromiseRejectionWarning: page.evaluate: TypeError: Cannot read properties of undefined (reading 'length')
    at new StorybookTestRunnerError (<anonymous>:58:34)
    at __throwError (<anonymous>:71:15)
    at eval (eval at evaluate (:192:30), <anonymous>:4:19)
    at UtilityScript.evaluate (<anonymous>:194:17)
    at UtilityScript.<anonymous> (<anonymous>:1:44)

This PR simply defaults logs to [], so I can correctly see that the underlying error is actually coming from a 3rd party library:

 Cannot read properties of null (reading 'focus')

Version

Published prerelease version: v0.8.0-next.1

Changelog

🚀 Enhancement

🐛 Bug Fix

Authors: 3

When running `yarn test-storybook` on my story, a 3rd party library throws an uncaught exception, but `StorybookTestRunnerError` _assumes_ `logs` is an array, which throws this error:

```console
UnhandledPromiseRejectionWarning: page.evaluate: TypeError: Cannot read properties of undefined (reading 'length')
    at new StorybookTestRunnerError (<anonymous>:58:34)
    at __throwError (<anonymous>:71:15)
    at eval (eval at evaluate (:192:30), <anonymous>:4:19)
    at UtilityScript.evaluate (<anonymous>:194:17)
    at UtilityScript.<anonymous> (<anonymous>:1:44)
```

This PR simply **defaults `logs` to `[]`**, so I can correctly see that the underlying error is _actually_ coming from a 3rd party library:

```console
 Cannot read properties of null (reading 'focus')
```
@yannbf yannbf added the patch Increment the patch version when merged label Oct 7, 2022
Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much @ericclemmons !!!

@yannbf yannbf merged commit b45bd34 into storybookjs:next Oct 7, 2022
@yannbf yannbf mentioned this pull request Oct 7, 2022
@github-actions
Copy link

github-actions bot commented Oct 7, 2022

🚀 PR was released in v0.8.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants