Skip to content

Commit

Permalink
adding from key
Browse files Browse the repository at this point in the history
  • Loading branch information
prklm10 committed Nov 27, 2024
1 parent 9b389ba commit d5c9b3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 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), 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' })
withPage(percy, aboutUrl, p => p.eval(evalStorybookEnvironmentInfo), undefined, { from: 'about url' }),
withPage(percy, previewUrl, p => p.eval(evalStorybookStorySnapshots), undefined, { from: 'preview url' })
]);

// map stories to snapshot options
Expand Down
10 changes: 5 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ export async function* withPage(percy, url, callback, retry, args) {
} catch (error) {
attempt++;
let enableRetry = process.env.PERCY_RETRY_STORY_ON_ERROR || 'true';
const from = args?.from;
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 (from) {
error.message = `${from}: \n${error.message}`;
}
if (snapshotName) {
error.message = `Snapshot Name: ${snapshotName}: \n${error.message}`;
Expand All @@ -210,9 +210,9 @@ export async function* withPage(percy, url, callback, retry, args) {
if (args?.snapshotName) {
log.warn(`Retrying Story: ${args.snapshotName}, attempt: ${attempt}`);
}
if (args?.from) {
if (from) {
log.warn(
`Retrying because error occurred in: ${args.from}, attempt: ${attempt}`
`Retrying because error occurred in: ${from}, attempt: ${attempt}`
);
}
}
Expand Down

0 comments on commit d5c9b3d

Please sign in to comment.