mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
test: print instruction for creating missing snapshot in assertSnapshot
PR-URL: https://github.com/nodejs/node/pull/48914 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
1 parent
7778e190b0
commit
a2ca1a605f
1 file changed
+11
-1
@@ -42,7 +42,17 @@ async function assertSnapshot(actual, filename = process.argv[1]) {
|
||||
if (process.env.NODE_REGENERATE_SNAPSHOTS) {
|
||||
await fs.writeFile(snapshot, actual);
|
||||
} else {
|
||||
const expected = await fs.readFile(snapshot, 'utf8');
|
||||
let expected;
|
||||
try {
|
||||
expected = await fs.readFile(snapshot, 'utf8');
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT') {
|
||||
console.log(
|
||||
'Snapshot file does not exist. You can create a new one by running the test with NODE_REGENERATE_SNAPSHOTS=1',
|
||||
);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
assert.strictEqual(actual, replaceWindowsLineEndings(expected));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user