-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Cleaner error handling for storiesOf #672
Conversation
Our entire storybook was broken because of a simple error, we provided `undefined` as the first parameter of `storiesOf`. This was pretty hard to track down as it only results in issues later on during the runtime where storybook tries to manipulate the names that were given to the stories.
@@ -24,6 +24,10 @@ export default class ClientApi { | |||
} | |||
|
|||
storiesOf(kind, m) { | |||
if (!kind) { | |||
throw "Invalid kind provided for stories"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build's failing because of a couple simple linting errors.
This should be throw new Error('Invalid kind provided for stories');
Also, remove the whitespace on line 30.
@@ -24,6 +24,10 @@ export default class ClientApi { | |||
} | |||
|
|||
storiesOf(kind, m) { | |||
if (!kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, it might be nice to have this be !kind && typeof kind !== 'string'
to be a bit stricter
Applied the changes |
Can we get this merged? Just stumbled upon the exact same issue again today causing a search for half an hour :) |
Thank you! |
Our entire storybook was broken because of a simple error, we provided
undefined
as the first parameter ofstoriesOf
.This was pretty hard to track down as it only results in issues later on during the runtime where storybook tries to manipulate the names that were given to the stories.
If you want I can write extra tests for this usecase, but I would like to know if this is something you want to work on first.