diff --git a/packages/cli-snapshot/src/snapshot.js b/packages/cli-snapshot/src/snapshot.js index e1c02f2d6..2a2ff9cbd 100644 --- a/packages/cli-snapshot/src/snapshot.js +++ b/packages/cli-snapshot/src/snapshot.js @@ -81,8 +81,8 @@ export const snapshot = command('snapshot', { if (file) { // load snapshots file let snapshots = yield loadSnapshotFile(file); - // accept a config object instead of an array of snapshots - let config = Array.isArray(snapshots) ? { snapshots } : snapshots; + // remove any references and accept an array of snapshots instead of an config object + let { references, ...config } = Array.isArray(snapshots) ? { snapshots } : snapshots; options = merge(config, { baseUrl, include, exclude }); } else if (serve) { // serve and snapshot a static directory diff --git a/packages/cli-snapshot/test/file.test.js b/packages/cli-snapshot/test/file.test.js index ce9d089f3..706ef6956 100644 --- a/packages/cli-snapshot/test/file.test.js +++ b/packages/cli-snapshot/test/file.test.js @@ -224,4 +224,24 @@ describe('percy snapshot ', () => { '[percy] Error: No snapshots found' ]); }); + + it('allows a top-level references object for .yaml references', async () => { + fs.writeFileSync('references.yaml', [ + 'references:', + ' ref: &ref Reference Snapshot', + 'snapshots:', + ' - url: http://localhost:8000/', + ' name: *ref' + ].join('\n')); + + await snapshot(['./references.yaml']); + + expect(logger.stderr).toEqual([]); + expect(logger.stdout).toEqual([ + '[percy] Percy has started!', + '[percy] Snapshot taken: Reference Snapshot', + '[percy] Uploading 1 snapshot...', + '[percy] Finalized build #1: https://percy.io/test/test/123' + ]); + }); });