summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/package.json8
-rw-r--r--tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/add.js3
-rw-r--r--tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/index.js3
-rw-r--r--tests/specs/node/require_export_from_parent_with_no_filename/__test__.jsonc13
-rw-r--r--tests/specs/node/require_export_from_parent_with_no_filename/main.cjs16
-rw-r--r--tests/specs/node/require_export_from_parent_with_no_filename/package.json5
6 files changed, 48 insertions, 0 deletions
diff --git a/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/package.json b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/package.json
new file mode 100644
index 000000000..43f07a235
--- /dev/null
+++ b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "@denotest/cjs-multiple-exports",
+ "version": "1.0.0",
+ "exports": {
+ ".": "./src/index.js",
+ "./add": "./src/add.js"
+ }
+} \ No newline at end of file
diff --git a/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/add.js b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/add.js
new file mode 100644
index 000000000..42c8a7c60
--- /dev/null
+++ b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/add.js
@@ -0,0 +1,3 @@
+module.exports = function add(a, b) {
+ return a + b;
+}; \ No newline at end of file
diff --git a/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/index.js b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/index.js
new file mode 100644
index 000000000..432ed652e
--- /dev/null
+++ b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/index.js
@@ -0,0 +1,3 @@
+module.exports = {
+ hello: "world"
+}; \ No newline at end of file
diff --git a/tests/specs/node/require_export_from_parent_with_no_filename/__test__.jsonc b/tests/specs/node/require_export_from_parent_with_no_filename/__test__.jsonc
new file mode 100644
index 000000000..a3de08e46
--- /dev/null
+++ b/tests/specs/node/require_export_from_parent_with_no_filename/__test__.jsonc
@@ -0,0 +1,13 @@
+{
+ "tempDir": true,
+ "steps": [
+ {
+ "args": "install",
+ "output": "[WILDCARD]"
+ },
+ {
+ "args": "run -A main.cjs",
+ "output": "3\n"
+ }
+ ]
+}
diff --git a/tests/specs/node/require_export_from_parent_with_no_filename/main.cjs b/tests/specs/node/require_export_from_parent_with_no_filename/main.cjs
new file mode 100644
index 000000000..3335ae1bf
--- /dev/null
+++ b/tests/specs/node/require_export_from_parent_with_no_filename/main.cjs
@@ -0,0 +1,16 @@
+const path = require("node:path");
+const Module = require("node:module");
+function requireFromString(code, filename) {
+ const paths = Module._nodeModulePaths((0, path.dirname)(filename));
+ const m = new Module(filename, module.parent);
+ m.paths = paths;
+ m._compile(code, filename);
+ return m.exports;
+}
+
+const code = `
+const add = require("@denotest/cjs-multiple-exports/add");
+
+console.log(add(1, 2));
+`;
+requireFromString(code, "fake.js");
diff --git a/tests/specs/node/require_export_from_parent_with_no_filename/package.json b/tests/specs/node/require_export_from_parent_with_no_filename/package.json
new file mode 100644
index 000000000..9cd643895
--- /dev/null
+++ b/tests/specs/node/require_export_from_parent_with_no_filename/package.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "@denotest/cjs-multiple-exports": "1.0.0"
+ }
+}