summaryrefslogtreecommitdiff
path: root/tests/unit_node
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_node')
-rw-r--r--tests/unit_node/worker_threads_test.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/unit_node/worker_threads_test.ts b/tests/unit_node/worker_threads_test.ts
index a96896ce5..bc2becd66 100644
--- a/tests/unit_node/worker_threads_test.ts
+++ b/tests/unit_node/worker_threads_test.ts
@@ -10,6 +10,7 @@ import {
import { fromFileUrl, relative, SEPARATOR } from "@std/path/mod.ts";
import * as workerThreads from "node:worker_threads";
import { EventEmitter, once } from "node:events";
+import process from "node:process";
Deno.test("[node/worker_threads] BroadcastChannel is exported", () => {
assertEquals<unknown>(workerThreads.BroadcastChannel, BroadcastChannel);
@@ -486,3 +487,31 @@ Deno.test({
await worker.terminate();
},
});
+
+Deno.test({
+ name: "[node/worker_threads] Worker env using process.env",
+ async fn() {
+ const deferred = Promise.withResolvers<void>();
+ const worker = new workerThreads.Worker(
+ `
+ import { parentPort } from "node:worker_threads";
+ import process from "node:process";
+ parentPort.postMessage("ok");
+ `,
+ {
+ eval: true,
+ // Make sure this doesn't throw `DataCloneError`.
+ // See https://github.com/denoland/deno/issues/23522.
+ env: process.env,
+ },
+ );
+
+ worker.on("message", (data) => {
+ assertEquals(data, "ok");
+ deferred.resolve();
+ });
+
+ await deferred.promise;
+ await worker.terminate();
+ },
+});