Skip to content

Commit

Permalink
addressig comments
Browse files Browse the repository at this point in the history
  • Loading branch information
prklm10 committed Nov 26, 2024
1 parent 2ab8fdc commit 9b389ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ export async function* takeStorybookSnapshots(percy, callback, { baseUrl, flags

// gather storybook data in parallel
let [environmentInfo, stories] = yield* yieldAll([
withPage(percy, aboutUrl, p => p.eval(evalStorybookEnvironmentInfo)),
withPage(percy, previewUrl, p => p.eval(evalStorybookStorySnapshots))
withPage(percy, aboutUrl, p => p.eval(evalStorybookEnvironmentInfo), undefined, { from: 'about url', errorMessage: 'Unable to load about url' }),
withPage(percy, previewUrl, p => p.eval(evalStorybookStorySnapshots), undefined, { from: 'preview url', errorMessage: 'Unable to load preview url' })
]);

// map stories to snapshot options
Expand Down
17 changes: 14 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ export async function* withPage(percy, url, callback, retry, args) {
let retries = 3;
while (attempt < retries) {
try {
if (attempt > 0) {
log.warn(`Retrying Story: ${args?.snapshotName}, attempt: ${attempt}`);
}
// provide discovery options that may impact how the page loads
let page = yield percy.browser.page({
networkIdleTimeout: percy.config.discovery.networkIdleTimeout,
Expand Down Expand Up @@ -199,11 +196,25 @@ export async function* withPage(percy, url, callback, retry, args) {
if (!(enableRetry === 'true') || attempt === retries) {
// Add snapshotName to the error message
const snapshotName = args?.snapshotName;
const errorMessage = args?.errorMessage;
if (errorMessage) {
error.message = `${errorMessage}: \n${error.message}`;
}
if (snapshotName) {
error.message = `Snapshot Name: ${snapshotName}: \n${error.message}`;
}
throw error;
}

// only throw warning message on snapshot
if (args?.snapshotName) {
log.warn(`Retrying Story: ${args.snapshotName}, attempt: ${attempt}`);
}
if (args?.from) {
log.warn(
`Retrying because error occurred in: ${args.from}, attempt: ${attempt}`
);
}
}
}
}
Expand Down

0 comments on commit 9b389ba

Please sign in to comment.