Skip to content

Commit 83dcbb7

Browse files
committed
test: print instruction for creating missing snapshot in
PR-URL: nodejs/node#48914 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent b4d768e commit 83dcbb7

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

graal-nodejs/test/common/assertSnapshot.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,17 @@ async function assertSnapshot(actual, filename = process.argv[1]) {
4242
if (process.env.NODE_REGENERATE_SNAPSHOTS) {
4343
await fs.writeFile(snapshot, actual);
4444
} else {
45-
const expected = await fs.readFile(snapshot, 'utf8');
45+
let expected;
46+
try {
47+
expected = await fs.readFile(snapshot, 'utf8');
48+
} catch (e) {
49+
if (e.code === 'ENOENT') {
50+
console.log(
51+
'Snapshot file does not exist. You can create a new one by running the test with NODE_REGENERATE_SNAPSHOTS=1',
52+
);
53+
}
54+
throw e;
55+
}
4656
assert.strictEqual(actual, replaceWindowsLineEndings(expected));
4757
}
4858
}

0 commit comments

Comments
 (0)