diff --git a/src/snapshots.js b/src/snapshots.js index 5d17eda3..ce6c4109 100644 --- a/src/snapshots.js +++ b/src/snapshots.js @@ -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 diff --git a/src/start.js b/src/start.js index 3e9e0239..5fa2b302 100644 --- a/src/start.js +++ b/src/start.js @@ -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'); diff --git a/src/storybook.js b/src/storybook.js index 6d0fe05c..b541f35d 100644 --- a/src/storybook.js +++ b/src/storybook.js @@ -24,8 +24,7 @@ export const storybook = command('storybook', { ], percy: { - delayUploads: true, - deferUploads: true + delayUploads: true }, config: {