diff --git a/packages/config/src/validate.js b/packages/config/src/validate.js index 1460ba8d5..1a29683b8 100644 --- a/packages/config/src/validate.js +++ b/packages/config/src/validate.js @@ -158,8 +158,7 @@ function shouldHideError(key, path, error) { let { parentSchema, keyword, schemaPath } = error; return !(parentSchema.error || parentSchema.errors?.[keyword]) && ( - HIDE_NESTED_KEYWORDS.some(k => schemaPath.includes(`/${k}`)) || - getSchema(key, path)[path.length] !== parentSchema + HIDE_NESTED_KEYWORDS.some(k => schemaPath.includes(`/${k}`)) ); } diff --git a/packages/core/src/snapshot.js b/packages/core/src/snapshot.js index 9bf058f93..15b445764 100644 --- a/packages/core/src/snapshot.js +++ b/packages/core/src/snapshot.js @@ -158,6 +158,7 @@ export function validateSnapshotOptions(options) { // add back snapshots before validating and scrubbing; function snapshots are validated later if (snapshots) migrated.snapshots = typeof snapshots === 'function' ? [] : snapshots; + else if (!isSnapshot && options.snapshots) migrated.snapshots = []; let errors = PercyConfig.validate(migrated, schema); if (errors) { diff --git a/packages/core/test/snapshot-multiple.test.js b/packages/core/test/snapshot-multiple.test.js index eae935c33..da9f83238 100644 --- a/packages/core/test/snapshot-multiple.test.js +++ b/packages/core/test/snapshot-multiple.test.js @@ -136,6 +136,15 @@ describe('Snapshot multiple', () => { 'Missing required URL for snapshot' ); }); + + it('rejects when missing snapshots', async () => { + await expectAsync( + percy.snapshot({ baseUrl, snapshots: () => [] }) + ).toBeRejectedWithError('No snapshots found'); + + expect(logger.stdout).toEqual([]); + expect(logger.stderr).toEqual([]); + }); }); describe('sitemap syntax', () => {