Skip to content

Commit

Permalink
feat: throw error or constant string when err missing
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshah98 committed Nov 2, 2023
1 parent 254b326 commit 6376d33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ export function evalSetCurrentStory({ waitFor }, story) {
// resolve when rendered, reject on any other renderer event
return new Promise((resolve, reject) => {
channel.on('storyRendered', resolve);
channel.on('storyMissing', () => reject(new Error('Story Missing')));
channel.on('storyErrored', () => reject(new Error('Story Errored')));
channel.on('storyThrewException', () => reject(new Error('Story Threw Exception')));
channel.on('storyMissing', (err) => reject(err || new Error('Story Missing')));
channel.on('storyErrored', (err) => reject(err || new Error('Story Errored')));
channel.on('storyThrewException', (err) => reject(err || new Error('Story Threw Exception')));
});
});
}
6 changes: 3 additions & 3 deletions test/storybook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ describe('percy storybook', () => {

await expectAsync(storybook(['http://localhost:8000']))
// message contains the client stack trace
.toBeRejectedWithError(/^Story Errored\n.*\/iframe\.html.*$/s);
.toBeRejectedWithError(/^Story Error\n.*\/iframe\.html.*$/s);

expect(logger.stderr).toEqual([
'[percy] Build not created',
// message contains the client stack trace
jasmine.stringMatching(/^\[percy\] Error: Story Errored\n.*\/iframe\.html.*$/s)
jasmine.stringMatching(/^\[percy\] Error: Story Error\n.*\/iframe\.html.*$/s)
]);
});

Expand Down Expand Up @@ -191,7 +191,7 @@ describe('percy storybook', () => {
expect(logger.stderr).toEqual([
'[percy] Failed to capture story: foo: bar',
// error logs contain the client stack trace
jasmine.stringMatching(/^\[percy\] Error: Story Errored\n.*\/iframe\.html.*$/s),
jasmine.stringMatching(/^\[percy\] Error: Story Error\n.*\/iframe\.html.*$/s),
// does not create a build if all stories failed [ 1 in this case ]
'[percy] Build not created'
]);
Expand Down

0 comments on commit 6376d33

Please sign in to comment.