diff --git a/lib/csf-tools/src/CsfFile.test.ts b/lib/csf-tools/src/CsfFile.test.ts index 6bfa32456104..bcb3377a840a 100644 --- a/lib/csf-tools/src/CsfFile.test.ts +++ b/lib/csf-tools/src/CsfFile.test.ts @@ -613,5 +613,28 @@ describe('CsfFile', () => { __id: foo-bar--a `); }); + + it('Object export with storyName', () => { + expect( + parse( + dedent` + export default { title: 'foo/bar' }; + export const A = { + storyName: 'Apple' + } + `, + true + ) + ).toMatchInlineSnapshot(` + meta: + title: foo/bar + stories: + - id: foo-bar--a + name: Apple + parameters: + __isArgsStory: true + __id: foo-bar--a + `); + }); }); }); diff --git a/lib/csf-tools/src/CsfFile.ts b/lib/csf-tools/src/CsfFile.ts index 3d38d6a2f93d..ba312cd2dfb9 100644 --- a/lib/csf-tools/src/CsfFile.ts +++ b/lib/csf-tools/src/CsfFile.ts @@ -266,7 +266,10 @@ export class CsfFile { if (t.isIdentifier(p.key)) { if (p.key.name === 'render') { __isArgsStory = isArgsStory(p.value as t.Expression, parent, self); - } else if (p.key.name === 'name' && t.isStringLiteral(p.value)) { + } else if ( + (p.key.name === 'name' || p.key.name === 'storyName') && + t.isStringLiteral(p.value) + ) { name = p.value.value; } self._storyAnnotations[exportName][p.key.name] = p.value;