diff --git a/packages/core/src/discovery.js b/packages/core/src/discovery.js index 6c2136a8a..e0ebc8f8f 100644 --- a/packages/core/src/discovery.js +++ b/packages/core/src/discovery.js @@ -136,7 +136,8 @@ async function* captureSnapshotResources(page, snapshot, options) { for (let additionalSnapshot of [baseSnapshot, ...additionalSnapshots]) { let isBaseSnapshot = additionalSnapshot === baseSnapshot; let snap = { ...baseSnapshot, ...additionalSnapshot }; - let width, { widths, execute } = snap; + let { widths, execute } = snap; + let [width] = widths; // iterate over widths to trigger reqeusts and capture other widths if (isBaseSnapshot || captureWidths) { diff --git a/packages/core/src/snapshot.js b/packages/core/src/snapshot.js index ae66a2afe..ce8f19649 100644 --- a/packages/core/src/snapshot.js +++ b/packages/core/src/snapshot.js @@ -317,7 +317,7 @@ export function createSnapshotsQueue(percy) { if (percy.dryRun) percy.log.info(`Snapshot found: ${name}`, meta); // immediately flush when uploads are delayed but not skipped - if (percy.delayUploads && !percy.skipUploads) queue.flush(); + if (percy.delayUploads && !percy.deferUploads) queue.flush(); // overwrite any existing snapshot when not deferred or when resources is a function if (!percy.deferUploads || typeof snapshot.resources === 'function') return snapshot; // merge snapshot options when uploads are deferred diff --git a/packages/core/test/snapshot.test.js b/packages/core/test/snapshot.test.js index f1b60fd91..17afae504 100644 --- a/packages/core/test/snapshot.test.js +++ b/packages/core/test/snapshot.test.js @@ -365,6 +365,7 @@ describe('Snapshot', () => { // stop and recreate a percy instance with the desired option await percy.stop(true); await api.mock(); + logger.reset(); testDOM = `
@@ -379,7 +380,10 @@ describe('Snapshot', () => { percy = await Percy.start({ token: 'PERCY_TOKEN', - deferUploads: true + deferUploads: true, + loglevel: 'debug', + // delay should do nothing + delayUploads: true }); percy.snapshot({ @@ -397,6 +401,15 @@ describe('Snapshot', () => { await percy.stop(); + expect(logger.stderr).toEqual(jasmine.arrayContaining([ + '[percy:core:page] Taking snapshot: Snapshot 0 @600px', + '[percy:core:page] Taking snapshot: Snapshot 0 @1000px', + '[percy:core:page] Taking snapshot: Snapshot 0 @1600px', + '[percy:core:page] Taking snapshot: Snapshot 1 @600px', + '[percy:core:page] Taking snapshot: Snapshot 1 @1000px', + '[percy:core:page] Taking snapshot: Snapshot 1 @1600px' + ])); + // snapshots uploaded after stopping expect(api.requests['/builds/123/snapshots']).toHaveSize(2);