| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,7 +34,17 @@ async function assertSnapshot(actual, filename = process.argv[1]) { | |||
| 34 | 34 | if (process.env.NODE_REGENERATE_SNAPSHOTS) { | |
| 35 | 35 | await fs.writeFile(snapshot, actual); | |
| 36 | 36 | } else { | |
| 37 | - const expected = await fs.readFile(snapshot, 'utf8'); | ||
| 37 | + let expected; | ||
| 38 | + try { | ||
| 39 | + expected = await fs.readFile(snapshot, 'utf8'); | ||
| 40 | + } catch (e) { | ||
| 41 | + if (e.code === 'ENOENT') { | ||
| 42 | + console.log( | ||
| 43 | + 'Snapshot file does not exist. You can create a new one by running the test with NODE_REGENERATE_SNAPSHOTS=1', | ||
| 44 | + ); | ||
| 45 | + } | ||
| 46 | + throw e; | ||
| 47 | + } | ||
| 38 | 48 | assert.strictEqual(actual, replaceWindowsLineEndings(expected)); | |
| 39 | 49 | } | |
| 40 | 50 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments