| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,17 @@ async function assertSnapshot(actual, filename = process.argv[1]) { | |||
| 42 | 42 | if (process.env.NODE_REGENERATE_SNAPSHOTS) { | |
| 43 | 43 | await fs.writeFile(snapshot, actual); | |
| 44 | 44 | } 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 | + } | ||
| 46 | 56 | assert.strictEqual(actual, replaceWindowsLineEndings(expected)); | |
| 47 | 57 | } | |
| 48 | 58 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments