Skip to content

Commit

Permalink
CsfFile: Improve meta error handling and fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Jan 6, 2025
1 parent 84f2ae6 commit 3753cde
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion code/core/src/csf-tools/CsfFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2408,7 +2408,7 @@ describe('CsfFile', () => {
`);
});

it.only('local defineConfig', () => {
it('local defineConfig', () => {
expect(() =>
parse(
dedent`
Expand Down
18 changes: 13 additions & 5 deletions code/core/src/csf-tools/CsfFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,19 @@ export class CsfFile {
self._options.fileName
);
} else if (!self._metaIsFactory && storyIsFactory) {
throw new BadMetaError(
'meta() factory must be imported from .storybook/preview configuration',
storyNode as t.Node,
self._options.fileName
);
if (self._metaNode) {
throw new MixedFactoryError(
'expected non-factory story',
storyNode as t.Node,
self._options.fileName
);
} else {
throw new BadMetaError(
'meta() factory must be imported from .storybook/preview configuration',
storyNode as t.Node,
self._options.fileName
);
}
}
const parameters: { [key: string]: any } = {};
if (t.isObjectExpression(storyNode)) {
Expand Down

0 comments on commit 3753cde

Please sign in to comment.