diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-04-20 09:18:10 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-20 09:18:10 +0530 |
commit | e0554ac4a2da95ad98eef36246283cb8f38a3afe (patch) | |
tree | 52956622a178a4d3d108ab1274052bd022ff8ac1 /tests/unit_node/worker_threads_test.ts | |
parent | 9425dce6dbc3a10bbde963d7a6192884c47185a5 (diff) |
fix(ext/node): Support `env` option in worker_thread (#23462)
Fixes https://github.com/denoland/deno/issues/23455
Diffstat (limited to 'tests/unit_node/worker_threads_test.ts')
-rw-r--r-- | tests/unit_node/worker_threads_test.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit_node/worker_threads_test.ts b/tests/unit_node/worker_threads_test.ts index 21bbca194..a96896ce5 100644 --- a/tests/unit_node/worker_threads_test.ts +++ b/tests/unit_node/worker_threads_test.ts @@ -460,3 +460,29 @@ Deno.test("[node/worker_threads] receiveMessageOnPort works if there's pending r port5.close(); port6.close(); }); + +Deno.test({ + name: "[node/worker_threads] Worker 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(process.env.TEST_ENV); + `, + { + eval: true, + env: { TEST_ENV: "test" }, + }, + ); + + worker.on("message", (data) => { + assertEquals(data, "test"); + deferred.resolve(); + }); + + await deferred.promise; + await worker.terminate(); + }, +}); |