Core: Throw an error for invalid story format #13673
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
When mistakenly a user writes a story such as:
rather than:
Storybook fails with an error that is not very helpful:

What I did
This PR adds a check in the client api that will break Storybook if the story received is not a function telling exactly which story is broken. It's a similar mechanism than the one that checks if
storyNameis not a string.Here's how it looks like:

I personally find it quite useful that Storybook breaks entirely because it tells the users that there is a critical error given that their stories are broken and it forces them to fix the problem right away.
How to test
1 - check the branch
2 -
yarn build client-api3 - add this to any of the example stories:
4 - run Storybook (e.g.
yarn start)