Skip to content

Commit

Permalink
test: print instruction for creating missing snapshot in
Browse files Browse the repository at this point in the history
PR-URL: nodejs/node#48914
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
sercher committed Apr 25, 2024
1 parent b4d768e commit 83dcbb7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion graal-nodejs/test/common/assertSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down

0 comments on commit 83dcbb7

Please sign in to comment.