Skip to content

Commit

Permalink
feat: make updateSnapshotState sync again
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Apr 3, 2021
1 parent 4531d84 commit 09033d8
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions packages/jest-core/src/TestScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = !!(
Expand Down

0 comments on commit 09033d8

Please sign in to comment.