diff --git a/code/lib/preview-api/src/modules/store/csf/portable-stories.test.ts b/code/lib/preview-api/src/modules/store/csf/portable-stories.test.ts index eae92f09aac8..f21919bf437f 100644 --- a/code/lib/preview-api/src/modules/store/csf/portable-stories.test.ts +++ b/code/lib/preview-api/src/modules/store/csf/portable-stories.test.ts @@ -52,14 +52,14 @@ describe('composeStory', () => { ); }); - it('should throw when executing the play function but the story does not have one', async () => { + it('should not throw when executing the play function but the story does not have one', async () => { const Story = () => {}; Story.args = { primary: true, }; const composedStory = composeStory(Story, meta); - expect(composedStory.play({ canvasElement: null })).rejects.toThrow(); + await expect(composedStory.play({ canvasElement: null })).resolves.toBeUndefined(); }); it('should throw an error if Story is undefined', () => { diff --git a/code/lib/preview-api/src/modules/store/csf/portable-stories.ts b/code/lib/preview-api/src/modules/store/csf/portable-stories.ts index 0ebf858e96e8..3dbcd73d9a23 100644 --- a/code/lib/preview-api/src/modules/store/csf/portable-stories.ts +++ b/code/lib/preview-api/src/modules/store/csf/portable-stories.ts @@ -102,14 +102,12 @@ export function composeStory, id: story.id, play: (async (extraContext: ComposedStoryPlayContext) => { - if (story.playFunction === undefined) { - throw new Error('The story does not have a play function. Make sure to add one.'); + if (typeof story.playFunction === 'function') { + await story.playFunction({ + ...context, + ...extraContext, + }); } - - await story.playFunction({ - ...context, - ...extraContext, - }); }) as unknown as ComposedStoryPlayFn>, } );