diff --git a/code/lib/csf-tools/src/CsfFile.test.ts b/code/lib/csf-tools/src/CsfFile.test.ts index 7e0d223a23af..21e902cce52f 100644 --- a/code/lib/csf-tools/src/CsfFile.test.ts +++ b/code/lib/csf-tools/src/CsfFile.test.ts @@ -619,7 +619,7 @@ describe('CsfFile', () => { }); it('no metadata', () => { - expect(() => + expect( parse( dedent` export default { foo: '5' }; @@ -627,7 +627,15 @@ describe('CsfFile', () => { export const B = () => {}; ` ) - ).toThrow('CSF: missing title/component'); + ).toMatchInlineSnapshot(` + meta: + title: Default Title + stories: + - id: default-title--a + name: A + - id: default-title--b + name: B + `); }); it('dynamic titles', () => { diff --git a/code/lib/csf-tools/src/CsfFile.ts b/code/lib/csf-tools/src/CsfFile.ts index f1cce083da96..4516a293b1cc 100644 --- a/code/lib/csf-tools/src/CsfFile.ts +++ b/code/lib/csf-tools/src/CsfFile.ts @@ -478,14 +478,6 @@ export class CsfFile { throw new NoMetaError('missing default export', self._ast, self._fileName); } - if (!self._meta.title && !self._meta.component) { - throw new Error(dedent` - CSF: missing title/component ${formatLocation(self._ast, self._fileName)} - - More info: https://storybook.js.org/docs/react/writing-stories#default-export - `); - } - // default export can come at any point in the file, so we do this post processing last const entries = Object.entries(self._stories); self._meta.title = this._makeTitle(self._meta?.title as string);