summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/node_compat/config.jsonc1
-rw-r--r--cli/tests/node_compat/test/fixtures/run-main.js1
-rw-r--r--cli/tests/node_compat/test/parallel/test-module-run-main.js15
3 files changed, 17 insertions, 0 deletions
diff --git a/cli/tests/node_compat/config.jsonc b/cli/tests/node_compat/config.jsonc
index 81463bcaf..87530d4f5 100644
--- a/cli/tests/node_compat/config.jsonc
+++ b/cli/tests/node_compat/config.jsonc
@@ -366,6 +366,7 @@
"test-http-outgoing-message-inheritance.js",
"test-http-outgoing-renderHeaders.js",
"test-http-outgoing-settimeout.js",
+ "test-module-run-main.js",
"test-net-access-byteswritten.js",
"test-net-better-error-messages-listen-path.js",
"test-net-better-error-messages-path.js",
diff --git a/cli/tests/node_compat/test/fixtures/run-main.js b/cli/tests/node_compat/test/fixtures/run-main.js
new file mode 100644
index 000000000..9a081cbba
--- /dev/null
+++ b/cli/tests/node_compat/test/fixtures/run-main.js
@@ -0,0 +1 @@
+globalThis.foo = 42;
diff --git a/cli/tests/node_compat/test/parallel/test-module-run-main.js b/cli/tests/node_compat/test/parallel/test-module-run-main.js
new file mode 100644
index 000000000..8e30de267
--- /dev/null
+++ b/cli/tests/node_compat/test/parallel/test-module-run-main.js
@@ -0,0 +1,15 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+"use strict";
+
+const Module = require("module");
+const assert = require("assert/strict");
+const path = require("path");
+
+const file = path.join(__dirname, "..", "fixtures", "run-main.js");
+process.argv = [process.argv[0], file];
+Module.runMain();
+
+// The required file via `Module.runMain()` sets this global
+assert.equal(globalThis.foo, 42);