Skip to content

Commit

Permalink
feat(cli): write snapshot files in parallel
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
  • Loading branch information
bajtos committed Sep 26, 2019
1 parent c6959b8 commit a16ae34
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/cli/test/snapshot-matcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ variable to update snapshots.
}

const snapshots = Object.create(null);
after(function updateSnapshots() {
for (const f in snapshots) {
after(async function updateSnapshots() {
const tasks = Object.entries(snapshots).map(([f, data]) => {
const snapshotFile = buildSnapshotFilePath(snapshotDir, f);
writeSnapshotData(snapshotFile, snapshots[f]);
}
return writeSnapshotData(snapshotFile, data);
});
await Promise.all(tasks);
});

return function expectToRecordSnapshot(actual) {
Expand Down Expand Up @@ -200,7 +201,7 @@ function writeSnapshotData(snapshotFile, snapshots) {

const content = header + entries.join('\n');
mkdirp.sync(path.dirname(snapshotFile));
writeFileAtomic.sync(snapshotFile, content, {encoding: 'utf-8'});
return writeFileAtomic(snapshotFile, content, {encoding: 'utf-8'});
}

function buildSnapshotCode(key, value) {
Expand Down

0 comments on commit a16ae34

Please sign in to comment.