Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 ✨Fix eval setCurrentStory error + make logging better #837

Merged
merged 5 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ export async function* takeStorybookSnapshots(percy, callback, { baseUrl, flags
while (snapshots.length) {
try {
// use a single page to capture story snapshots without reloading
yield* withPage(percy, previewUrl, async function*(page) {
// loading an existing story instead of just iframe.html as that triggers `storyMissing` event
itsjwala marked this conversation as resolved.
Show resolved Hide resolved
// This in turn leads to promise rejection and failure
yield* withPage(percy, `${previewUrl}?id=${snapshots[0].id}&viewMode=story`, async function*(page) {
itsjwala marked this conversation as resolved.
Show resolved Hide resolved
// determines when to retry page crashes
lastCount = snapshots.length;

Expand Down
8 changes: 4 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export async function* withPage(percy, url, callback, retry) {
return yield* yieldTo(callback(page));
} catch (error) {
// if the page crashed and retry returns truthy, try again
if (error?.message?.includes('crashed') && retry?.()) {
if (error.message?.includes('crashed') && retry?.()) {
return yield* withPage(...arguments);
}

Expand Down 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);
channel.on('storyErrored', reject);
channel.on('storyThrewException', reject);
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')));
});
});
}