From 7a8f57c4e527f7fc84b85a4757723bb97540ebc3 Mon Sep 17 00:00:00 2001 From: Vlad Sirenko Date: Tue, 1 Aug 2023 05:41:41 +0300 Subject: throw error if node module does not exist (#3913) --- test/js/node/missing-module.test.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 test/js/node/missing-module.test.js (limited to 'test/js/node/missing-module.test.js') diff --git a/test/js/node/missing-module.test.js b/test/js/node/missing-module.test.js new file mode 100644 index 000000000..fd772441a --- /dev/null +++ b/test/js/node/missing-module.test.js @@ -0,0 +1,7 @@ +import { expect, test } from "bun:test"; + +test("not implemented yet module masquerades as undefined and throws an error", () => { + const missingModule = "node:missing" + ""; + expect(() => require(missingModule)).toThrow(/^Cannot find package "node:missing" from "/); + expect(() => import(missingModule)).toThrow(/^Cannot find package "node:missing" from "/); +}); -- cgit v1.2.3