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

Stories that are excluded cause errors #137

@radfahrer

Description

@radfahrer

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:

  1. Write a story and export it
  2. import the story into a test file
  3. use ComposeStories to generate a fixure
  4. write a test using React Testing Library to render the fixture
  5. run the test and see that it does not throw an error
  6. go back to the story file
  7. add the story to excludeStories
  8. rerun the test

Actual Result
The error above.

Expected behavior

No error.

Screenshots
Screen Shot 2023-02-23 at 11 11 31 AM

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions