aboutsummaryrefslogtreecommitdiff
path: root/test/js/node/disabled-module.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-11 19:14:34 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-11 19:14:34 -0700
commitcbb88672f217a90db1aa1eb29cd92d5d9035b22b (patch)
tree43a00501f3cde495967e116f0b660777051551f8 /test/js/node/disabled-module.test.js
parent1f900cff453700b19bca2acadfe26da4468c1282 (diff)
parent34b0e7a2bbd8bf8097341cdb0075d0908283e834 (diff)
downloadbun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.tar.gz
bun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.tar.zst
bun-cbb88672f217a90db1aa1eb29cd92d5d9035b22b.zip
Merge branch 'main' into jarred/esm-conditionsjarred/esm-conditions
Diffstat (limited to 'test/js/node/disabled-module.test.js')
-rw-r--r--test/js/node/disabled-module.test.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/test/js/node/disabled-module.test.js b/test/js/node/disabled-module.test.js
index d02a6b6df..bb707a122 100644
--- a/test/js/node/disabled-module.test.js
+++ b/test/js/node/disabled-module.test.js
@@ -1,15 +1,16 @@
import { expect, test } from "bun:test";
+import { AsyncResource, AsyncLocalStorage } from "async_hooks";
+import * as worker_threads from "worker_threads";
+import worker_threads_default from "worker_threads";
test("not implemented yet module masquerades as undefined and throws an error", () => {
- const worker_threads = import.meta.require("worker_threads");
-
- expect(typeof worker_threads).toBe("undefined");
+ expect(typeof worker_threads.default).toBe("undefined");
+ expect(typeof worker_threads_default).toBe("undefined");
expect(typeof worker_threads.getEnvironmentData).toBe("undefined");
+ expect(typeof worker_threads_default.getEnvironmentData).toBe("undefined");
});
test("AsyncLocalStorage polyfill", () => {
- const { AsyncLocalStorage } = import.meta.require("async_hooks");
-
const store = new AsyncLocalStorage();
var called = false;
expect(store.getStore()).toBe(null);
@@ -22,8 +23,6 @@ test("AsyncLocalStorage polyfill", () => {
});
test("AsyncResource polyfill", () => {
- const { AsyncResource } = import.meta.require("async_hooks");
-
const resource = new AsyncResource("prisma-client-request");
var called = false;
resource.runInAsyncScope(
@@ -36,3 +35,9 @@ test("AsyncResource polyfill", () => {
);
expect(called).toBe(true);
});
+
+test("esbuild functions with worker_threads stub", async () => {
+ const esbuild = await import("esbuild");
+ const result = await esbuild.transform('console . log( "hello world" )', { minify: true });
+ expect(result.code).toBe('console.log("hello world");\n');
+});