ncjsm/test/is-module-not-found-error/index.js
raw| 1 | "use strict"; |
| 2 | |
| 3 | const { resolve } = require("path"); |
| 4 | |
| 5 | const pg = resolve(__dirname, "../__playground/is-module-not-found-error"); |
| 6 | |
| 7 | module.exports = function (t, a) { |
| 8 | let path; |
| 9 | try { |
| 10 | require((path = "./wrong/path")); |
| 11 | a.never("Wrong path"); |
| 12 | } catch (e) { |
| 13 | a(t(e, path), true, "Wrong path"); |
| 14 | } |
| 15 | try { |
| 16 | require((path = `${ pg }/sample-error`)); |
| 17 | a.never("Evaluation error"); |
| 18 | } catch (e2) { |
| 19 | a(t(e2, path), false, "Syntax error"); |
| 20 | } |
| 21 | }; |