mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
chore: fix & update node compat config (#19106)
This commit is contained in:
parent
68c0fcb157
commit
2a0c664840
9 changed files with 31 additions and 41 deletions
|
@ -1,7 +1,8 @@
|
|||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { Module } from "node:module";
|
||||
import { assertStrictEquals } from "../../../test_util/std/testing/asserts.ts";
|
||||
import { assertEquals } from "../../../test_util/std/testing/asserts.ts";
|
||||
import process from "node:process";
|
||||
|
||||
Deno.test("[node/module _preloadModules] has internal require hook", () => {
|
||||
// Check if it's there
|
||||
|
@ -10,5 +11,17 @@ Deno.test("[node/module _preloadModules] has internal require hook", () => {
|
|||
"./cli/tests/unit_node/testdata/add_global_property.js",
|
||||
]);
|
||||
// deno-lint-ignore no-explicit-any
|
||||
assertStrictEquals((globalThis as any).foo, "Hello");
|
||||
assertEquals((globalThis as any).foo, "Hello");
|
||||
});
|
||||
|
||||
Deno.test("[node/module runMain] loads module using the current process.argv", () => {
|
||||
process.argv = [
|
||||
process.argv[0],
|
||||
"./cli/tests/unit_node/testdata/add_global_property_run_main.js",
|
||||
];
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
(Module as any).runMain();
|
||||
// deno-lint-ignore no-explicit-any
|
||||
assertEquals((globalThis as any).calledViaRunMain, true);
|
||||
});
|
||||
|
|
1
cli/tests/unit_node/testdata/add_global_property_run_main.js
vendored
Normal file
1
cli/tests/unit_node/testdata/add_global_property_run_main.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
globalThis.calledViaRunMain = true;
|
13
cli/tests/unit_node/worker_threads_test.ts
Normal file
13
cli/tests/unit_node/worker_threads_test.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { assertEquals } from "../../../test_util/std/testing/asserts.ts";
|
||||
import workerThreads from "node:worker_threads";
|
||||
|
||||
Deno.test("[node/worker_threads] BroadcastChannel is exported", () => {
|
||||
assertEquals<unknown>(workerThreads.BroadcastChannel, BroadcastChannel);
|
||||
});
|
||||
|
||||
Deno.test("[node/worker_threads] MessageChannel are MessagePort are exported", () => {
|
||||
assertEquals<unknown>(workerThreads.MessageChannel, MessageChannel);
|
||||
assertEquals<unknown>(workerThreads.MessagePort, MessagePort);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue