This repository was archived by the owner on Jan 31, 2024. It is now read-only.

Description
Describe the bug
When a story is excluded from the storybook via excludeStories it will throw errors in tests (React Testing Library) that render the story after it has been run through composeStories. The error is
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
To Reproduce
Steps to reproduce the behavior:
- Write a story and export it
- import the story into a test file
- use ComposeStories to generate a fixure
- write a test using React Testing Library to render the fixture
- run the test and see that it does not throw an error
- go back to the story file
- add the story to
excludeStories
- rerun the test
Actual Result
The error above.
Expected behavior
No error.
Screenshots

Additional context
The reason that this is a problem for us is that we rely heavily on Storys to provide test fixtures for our tests. We also use Apollo's MockedProvider to mock out graph responses. It is common for a Story to be written with specific mocks provided via a custom decorator just for the purposes of running a test with a specific graph response. Since these stories are not visually unique we use excludeStories to keep these test fixtures from cluttering up our Storybook.
Another piece of context is that we have been running @storybook/testing-react@0.0.21 and are trying to update it to 1.3.0. 0.0.21 does not throw this error.