storybookjs / testing-react

Testing utilities that allow you to reuse your Storybook stories in your React unit tests!
MIT License
588 stars 24 forks source link

`name` is changed when composing stories #107

Closed IanVS closed 2 years ago

IanVS commented 2 years ago

Describe the bug According to https://github.com/storybookjs/storybook/pull/18464#pullrequestreview-1003416977, name should be used for csf3 stories. However, when I run composeStory from testing-react, the name changes to something like composedStory2. I'd really like to have the name remain unchanged when composing stories.

To Reproduce https://github.com/IanVS/composed-story-name-reproduction

npm i
npm run storybook

Open the Primary Named story, which uses the Helper.jsx component to render a composed story as well as its name.

Expected behavior The name of the resulting story should be the csf3 name.

Screenshots

image
IanVS commented 2 years ago

I looked into this a bit, and there's no real way around it, since name is a protected property in composedStory, which is a function in composeStory. But, I see that it also already converts name into storyName, so I can use that. I've pushed up a small PR https://github.com/storybookjs/testing-react/pull/108 to add a test for this case. But, this issue can be closed out as-is.