mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
module pr 2 (#18266)
This commit is contained in:
@@ -1,7 +1,25 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { test, expect } from "bun:test";
|
||||
import assert from "assert";
|
||||
|
||||
test("not implemented yet module 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 '/);
|
||||
var missingModule = "node:missing";
|
||||
var missingBun = "bun:missing";
|
||||
var missingFile = "./filethatdoesntexist";
|
||||
var missingPackage = "package-that-doesnt-exist";
|
||||
|
||||
assert.throws(() => require(missingModule), {message: 'No such built-in module: node:missing', code: "ERR_UNKNOWN_BUILTIN_MODULE" });
|
||||
assert.throws(() => require.resolve(missingModule), {message: /Cannot find package 'node:missing' from/, code: "MODULE_NOT_FOUND" });
|
||||
assert.rejects(() => import(missingModule), {message: 'No such built-in module: node:missing', code: "ERR_UNKNOWN_BUILTIN_MODULE" });
|
||||
|
||||
assert.throws(() => require(missingBun), {message: /^Cannot find package 'bun:missing' from/, code: "MODULE_NOT_FOUND" });
|
||||
assert.throws(() => require.resolve(missingBun), {message: /^Cannot find package 'bun:missing' from/, code: "MODULE_NOT_FOUND" });
|
||||
assert.rejects(() => import(missingBun), {message: /^Cannot find package 'bun:missing' from/, code: "ERR_MODULE_NOT_FOUND" });
|
||||
|
||||
assert.throws(() => require(missingFile), {message: /^Cannot find module '\.\/filethatdoesntexist'/, code: "MODULE_NOT_FOUND" });
|
||||
assert.throws(() => require.resolve(missingFile), {message: /^Cannot find module '\.\/filethatdoesntexist'/, code: "MODULE_NOT_FOUND" });
|
||||
assert.rejects(() => import(missingFile), {message: /^Cannot find module '\.\/filethatdoesntexist'/, code: "ERR_MODULE_NOT_FOUND" });
|
||||
|
||||
assert.throws(() => require(missingPackage), {message: /^Cannot find package 'package-that-doesnt-exist'/, code: "MODULE_NOT_FOUND" });
|
||||
assert.throws(() => require.resolve(missingPackage), {message: /^Cannot find package 'package-that-doesnt-exist'/, code: "MODULE_NOT_FOUND" });
|
||||
assert.rejects(() => import(missingPackage), {message: /^Cannot find package 'package-that-doesnt-exist'/, code: "ERR_MODULE_NOT_FOUND" });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user