summaryrefslogtreecommitdiff
path: root/cli/tests/node_compat
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/node_compat')
-rw-r--r--cli/tests/node_compat/polyfill_globals.js25
-rw-r--r--cli/tests/node_compat/runner.ts1
2 files changed, 26 insertions, 0 deletions
diff --git a/cli/tests/node_compat/polyfill_globals.js b/cli/tests/node_compat/polyfill_globals.js
new file mode 100644
index 000000000..493cec87a
--- /dev/null
+++ b/cli/tests/node_compat/polyfill_globals.js
@@ -0,0 +1,25 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+import process from "node:process";
+import { Buffer } from "node:buffer";
+import {
+ clearImmediate,
+ clearInterval,
+ clearTimeout,
+ setImmediate,
+ setInterval,
+ setTimeout,
+} from "node:timers";
+import { performance } from "node:perf_hooks";
+import console from "node:console";
+globalThis.Buffer = Buffer;
+globalThis.clearImmediate = clearImmediate;
+globalThis.clearInterval = clearInterval;
+globalThis.clearTimeout = clearTimeout;
+globalThis.console = console;
+globalThis.global = globalThis;
+globalThis.performance = performance;
+globalThis.process = process;
+globalThis.setImmediate = setImmediate;
+globalThis.setInterval = setInterval;
+globalThis.setTimeout = setTimeout;
+delete globalThis.window;
diff --git a/cli/tests/node_compat/runner.ts b/cli/tests/node_compat/runner.ts
index f12cc69b0..93fca6548 100644
--- a/cli/tests/node_compat/runner.ts
+++ b/cli/tests/node_compat/runner.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+import "./polyfill_globals.js";
import { createRequire } from "node:module";
const file = Deno.args[0];
if (!file) {