Skip to content

Commit

Permalink
🐛 Fix cli-snapshot warning for top-level references option (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwilsman authored Jul 29, 2022
1 parent f1418fb commit 66c332f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/cli-snapshot/src/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions packages/cli-snapshot/test/file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,24 @@ describe('percy snapshot <file>', () => {
'[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'
]);
});
});

0 comments on commit 66c332f

Please sign in to comment.