Skip to content

Commit

Permalink
feat: defer deferUploads to user config
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshah98 committed Dec 1, 2023
1 parent b8f22df commit 0f433ac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
19 changes: 14 additions & 5 deletions src/snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,25 @@ export async function* takeStorybookSnapshots(percy, callback, { baseUrl, flags
// when not dry-running and javascript is not enabled, capture the story dom
yield page.eval(evalSetCurrentStory, { id, args, globals, queryParams });
/* istanbul ignore next: tested, but coverage is stripped */
for (let i = 0; i < percy.config.snapshot.widths.length; i++) {
let w = percy.config.snapshot.widths[i];
log.debug(`Capturing snapshot for width - ${w}`);
yield page.resize({ width: w, height: percy.config.snapshot.minHeight });
if (percy.config?.percy?.deferUploads) {
for (let i = 0; i < percy.config.snapshot.widths.length; i++) {
let w = percy.config.snapshot.widths[i];
log.debug(`Capturing snapshot for width - ${w}`);
yield page.resize({ width: w, height: percy.config.snapshot.minHeight });
let { dom, domSnapshot = dom } = yield page.snapshot(options);
options.domSnapshot = domSnapshot;
// validate without logging to prune all other options
PercyConfig.validate(options, '/snapshot/dom');
// validate without logging to prune all other options
percy.snapshot({ ...options, widths: [w] });
}
} else {
let { dom, domSnapshot = dom } = yield page.snapshot(options);
options.domSnapshot = domSnapshot;
// validate without logging to prune all other options
PercyConfig.validate(options, '/snapshot/dom');
// validate without logging to prune all other options
percy.snapshot({ ...options, widths: [w] });
percy.snapshot({ ...options });
}
}
// discard this story snapshot when done
Expand Down
3 changes: 1 addition & 2 deletions src/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export const start = command('start', {
],

percy: {
delayUploads: true,
deferUploads: true
delayUploads: true
}
}, async function*({ percy, flags, argv, log, exit }) {
if (!percy) exit(0, 'Percy is disabled');
Expand Down
3 changes: 1 addition & 2 deletions src/storybook.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export const storybook = command('storybook', {
],

percy: {
delayUploads: true,
deferUploads: true
delayUploads: true
},

config: {
Expand Down

0 comments on commit 0f433ac

Please sign in to comment.