From 09033d8f4cfea4719a1cb3f5b1d0afe6ad39f51e Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 3 Apr 2021 15:09:32 +1300 Subject: [PATCH] feat: make `updateSnapshotState` sync again --- packages/jest-core/src/TestScheduler.ts | 36 +++++++++++++++---------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/packages/jest-core/src/TestScheduler.ts b/packages/jest-core/src/TestScheduler.ts index 870e80b572bf..a813fcb026a8 100644 --- a/packages/jest-core/src/TestScheduler.ts +++ b/packages/jest-core/src/TestScheduler.ts @@ -158,21 +158,29 @@ export default class TestScheduler { }; const updateSnapshotState = async () => { - await Promise.all( - Array.from(contexts).map(async context => { - const status = snapshot.cleanup( - context.hasteFS, - this._globalConfig.updateSnapshot, - await snapshot.buildSnapshotResolver(context.config), - context.config.testPathIgnorePatterns, - ); - - aggregatedResults.snapshot.filesRemoved += status.filesRemoved; - aggregatedResults.snapshot.filesRemovedList = ( - aggregatedResults.snapshot.filesRemovedList || [] - ).concat(status.filesRemovedList); - }), + const contextsWithSnapshotResolvers = await Promise.all( + Array.from(contexts).map( + async context => + [ + context, + await snapshot.buildSnapshotResolver(context.config), + ] as const, + ), ); + + contextsWithSnapshotResolvers.forEach(([context, snapshotResolver]) => { + const status = snapshot.cleanup( + context.hasteFS, + this._globalConfig.updateSnapshot, + snapshotResolver, + context.config.testPathIgnorePatterns, + ); + + aggregatedResults.snapshot.filesRemoved += status.filesRemoved; + aggregatedResults.snapshot.filesRemovedList = ( + aggregatedResults.snapshot.filesRemovedList || [] + ).concat(status.filesRemovedList); + }); const updateAll = this._globalConfig.updateSnapshot === 'all'; aggregatedResults.snapshot.didUpdate = updateAll; aggregatedResults.snapshot.failure = !!(