Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add filename for obsolete snapshot file #8665

Merged
Prev Previous commit
Next Next commit
chore: use filter over reduce
  • Loading branch information
SimenB committed Jul 26, 2019
commit 3360711c66c7b31b1e2abc0ddb90a47d069cdcc5
8 changes: 4 additions & 4 deletions packages/jest-snapshot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ const cleanup = (
} => {
const pattern = '\\.' + EXTENSION + '$';
const files = hasteFS.matchFiles(pattern);
const list = files.reduce<Array<string>>((acc, snapshotFile) => {
const list = files.filter(snapshotFile => {
if (!fileExists(snapshotResolver.resolveTestPath(snapshotFile), hasteFS)) {
if (update === 'all') {
fs.unlinkSync(snapshotFile);
}
return [...acc, snapshotFile];
return true;
}

return acc;
}, []);
return false;
});

return {
filesRemoved: list.length,
Expand Down