summaryrefslogtreecommitdiff
path: root/tests/specs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-09-05 13:49:07 +0100
committerGitHub <noreply@github.com>2024-09-05 12:49:07 +0000
commit794d347ec68fa969ffed231d0844a59a215d2344 (patch)
tree237b26bba35eb570683de86f68e0bff9bde162dd /tests/specs
parentdda63287456aae5cd4f7f428e23b52cb8c0005e5 (diff)
fix: add suggestion how to fix importing CJS module (#21764)
``` $ cat exports_error.js Object.defineProperty(exports, "__esModule", { value: true }); $ deno exports_error.js error: Uncaught (in promise) ReferenceError: exports is not defined Object.defineProperty(exports, "__esModule", { value: true }); ^ at file:///exports_error.js:1:23 info: Deno doesn't support CommonJS modules without `.cjs` extension. hint: Rewrite this module to ESM or change the file extension to `.cjs`. ```
Diffstat (limited to 'tests/specs')
-rw-r--r--tests/specs/run/import_common_js/__test__.jsonc12
-rw-r--r--tests/specs/run/import_common_js/exports_error.js1
-rw-r--r--tests/specs/run/import_common_js/exports_error.out7
-rw-r--r--tests/specs/run/import_common_js/module_error.js3
-rw-r--r--tests/specs/run/import_common_js/module_error.out7
5 files changed, 29 insertions, 1 deletions
diff --git a/tests/specs/run/import_common_js/__test__.jsonc b/tests/specs/run/import_common_js/__test__.jsonc
index a09929cdd..950c7f68c 100644
--- a/tests/specs/run/import_common_js/__test__.jsonc
+++ b/tests/specs/run/import_common_js/__test__.jsonc
@@ -1,6 +1,16 @@
{
"steps": [
{ "args": "run -R index.cjs", "output": "index.out" },
- { "args": "run -R main.ts", "output": "main.out" }
+ { "args": "run -R main.ts", "output": "main.out" },
+ {
+ "args": "run module_error.js",
+ "output": "module_error.out",
+ "exitCode": 1
+ },
+ {
+ "args": "run exports_error.js",
+ "output": "exports_error.out",
+ "exitCode": 1
+ }
]
}
diff --git a/tests/specs/run/import_common_js/exports_error.js b/tests/specs/run/import_common_js/exports_error.js
new file mode 100644
index 000000000..a6a850fe2
--- /dev/null
+++ b/tests/specs/run/import_common_js/exports_error.js
@@ -0,0 +1 @@
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/tests/specs/run/import_common_js/exports_error.out b/tests/specs/run/import_common_js/exports_error.out
new file mode 100644
index 000000000..41eda2457
--- /dev/null
+++ b/tests/specs/run/import_common_js/exports_error.out
@@ -0,0 +1,7 @@
+error: Uncaught (in promise) ReferenceError: exports is not defined
+Object.defineProperty(exports, "__esModule", { value: true });
+ ^
+ at [WILDCARD]exports_error.js:1:23
+
+ info: Deno does not support CommonJS modules without `.cjs` extension.
+ hint: Rewrite this module to ESM or change the file extension to `.cjs`.
diff --git a/tests/specs/run/import_common_js/module_error.js b/tests/specs/run/import_common_js/module_error.js
new file mode 100644
index 000000000..59a3cc0e7
--- /dev/null
+++ b/tests/specs/run/import_common_js/module_error.js
@@ -0,0 +1,3 @@
+module.exports = {
+ foobar: "foobar",
+};
diff --git a/tests/specs/run/import_common_js/module_error.out b/tests/specs/run/import_common_js/module_error.out
new file mode 100644
index 000000000..53a908d29
--- /dev/null
+++ b/tests/specs/run/import_common_js/module_error.out
@@ -0,0 +1,7 @@
+error: Uncaught (in promise) ReferenceError: module is not defined
+module.exports = {
+^
+ at [WILDCARD]module_error.js:1:1
+
+ info: Deno does not support CommonJS modules without `.cjs` extension.
+ hint: Rewrite this module to ESM or change the file extension to `.cjs`.