import { describe, expect, test } from "bun:test"; const weirdInternalSpecifiers = [ "_http_agent", "_http_client", "_http_common", "_http_incoming", "_http_outgoing", "_http_server", "_stream_duplex", "_stream_passthrough", "_stream_readable", "_stream_transform", "_stream_wrap", "_stream_writable", "_tls_common", "_tls_wrap", ]; // Check that all the node modules comply with the expected interface in bun var specifiers = [ "assert", "assert/strict", "async_hooks", "buffer", "child_process", "cluster", "console", "constants", "crypto", "dgram", "diagnostics_channel", "dns", "dns/promises", "domain", "events", "fs", "fs/promises", "http", "http2", "https", "inspector", "inspector/promises", "module", "net", "os", "path", "path/posix", "path/win32", "perf_hooks", "process", "punycode", "querystring", "readline", "readline/promises", "repl", "stream", "stream/consumers", "stream/promises", "stream/web", "string_decoder", "sys", "timers", "timers/promises", "tls", "trace_events", "tty", "url", "util", "util/types", "v8", "vm", "worker_threads", "zlib", ]; specifiers = [...weirdInternalSpecifiers, ...specifiers.flatMap(a => ["node:" + a, a])]; for (let specifier of specifiers) { test(`stubbed CJS import.meta.require ${specifier}`, async () => { import.meta.require(specifier); }); test(`stubbed CJS require ${specifier}`, async () => { require(specifier); }); test(`stubbed import ${specifier}`, async () => { const mod = await import(specifier); if ("default" in mod) { expect(mod).toHaveProperty("default"); const cjs = mod.default[Symbol.for("CommonJS")]; if (typeof cjs !== "undefined") { if (cjs === 1) { expect(typeof mod.default).toBe("function"); } else if (cjs === true) { expect(cjs).toBe(true); if (typeof mod.default !== "undefined") { expect(typeof mod.default).toBe("function"); } } } } else { // TODO: uncomment this after node:module can be default imported // throw new Error(`Module ${specifier} has no default export`); } }); } // TODO: when node:vm is implemented, delete this test. test("node:vm", () => { const { Script } = import.meta.require("node:vm"); try { // **This line should appear in the stack trace** // That way it shows the "real" line causing the issue // Instead of several layers of wrapping new Script("1 + 1"); throw new Error("unreacahble"); } catch (e) { const msg = Bun.inspect(e); expect(msg).not.toContain("node:vm:"); expect(msg).toContain("**This line should appear in the stack trace**"); } }); e='dave/postinstall'>dave/postinstall Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/text-encoder.mjs (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-08-21RegenerateGravatar Jarred Sumner 1-8/+15
2023-08-21Implement FileGravatar Jarred Sumner 12-12/+387
2023-08-20Fixes #1675 (#4230)Gravatar Jarred Sumner 8-70/+297
2023-08-20Implement `--inspect-brk` (#4222)Gravatar Jarred Sumner 17-41/+101
2023-08-20Fix test failures from 3a9a6c63a (#4231)Gravatar Jarred Sumner 4-32/+34
2023-08-20Fix(bundler): use different alias mappings based on the target. (#4163)Gravatar Ai Hoshino 8-18/+90
2023-08-19Update BunDebugger.cppGravatar Jarred Sumner 1-1/+3
2023-08-19Introduce `bun --inspect-wait`Gravatar Jarred Sumner 3-19/+47
2023-08-19misc non-posix fixesGravatar Jarred Sumner 2-3/+3
2023-08-19Update lockfile.mdGravatar Jarred Sumner 1-1/+8
2023-08-19Update lockfile.mdGravatar Jarred Sumner 1-4/+4
2023-08-19Update lockfile.mdGravatar Jarred Sumner 1-1/+29
2023-08-19Update Dockerfile-distroless (#4210)Gravatar Omar 1-0/+1
2023-08-19Fix symbol visibilityGravatar Jarred Sumner 1-0/+1
2023-08-19[napi] Implement `node_api_create_syntax_error`, `node_api_symbol_for`, `nod...Gravatar Jarred Sumner 5-1/+70
2023-08-19Fix crash impacting sharp & resvg (#4221)Gravatar Jarred Sumner 5-73/+73
2023-08-19Fixes #172 (#4220)Gravatar Jarred Sumner 7-9/+87
2023-08-19Add inline sourcemaps when `--inspect` is enabled (#4213)Gravatar Jarred Sumner 3-3/+64
2023-08-19tty `ReadStream`, `WriteStream`, and readline rawmode (#4179)Gravatar Dylan Conway 23-722/+821
2023-08-18Fix make headers (again)Gravatar Jarred Sumner 1-0/+2