summaryrefslogtreecommitdiff
path: root/tests/specs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-09-05 07:25:56 +0100
committerGitHub <noreply@github.com>2024-09-05 08:25:56 +0200
commitacd01eb2b41e37a480943f79cfa28fc220c4baca (patch)
treea9808419bc88099fc811162d000007f6b2c30f9d /tests/specs
parent105c2e336a4312ed1714ab893c57eae2a19068c7 (diff)
feat: Add a hint on error about 'Relative import path ... not prefixed with ...' (#25430)
Running a file like: ``` import "@std/dotenv/load"; ``` Without a mapping in `imports` field of `deno.json` or `dependencies` of `package.json` will now error out with a hint: ``` error: Relative import path "@std/dotenv/load" not prefixed with / or ./ or ../ hint: Try running `deno add @std/dotenv/load` at [WILDCARD]bare_specifier_without_import/main.ts:1:8 ``` Closes https://github.com/denoland/deno/issues/24699 --------- Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
Diffstat (limited to 'tests/specs')
-rw-r--r--tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out1
-rw-r--r--tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out1
-rw-r--r--tests/specs/run/bare_specifier_without_import/__test__.jsonc5
-rw-r--r--tests/specs/run/bare_specifier_without_import/main.out3
-rw-r--r--tests/specs/run/bare_specifier_without_import/main.ts3
5 files changed, 13 insertions, 0 deletions
diff --git a/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out b/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out
index 2668a6e08..50daf8041 100644
--- a/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out
+++ b/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out
@@ -1,2 +1,3 @@
[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
+ hint: If you want to use a JSR or npm package, try running `deno add foo`
at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD]
diff --git a/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out b/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out
index 2668a6e08..50daf8041 100644
--- a/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out
+++ b/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out
@@ -1,2 +1,3 @@
[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
+ hint: If you want to use a JSR or npm package, try running `deno add foo`
at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD]
diff --git a/tests/specs/run/bare_specifier_without_import/__test__.jsonc b/tests/specs/run/bare_specifier_without_import/__test__.jsonc
new file mode 100644
index 000000000..7b5c5e1b6
--- /dev/null
+++ b/tests/specs/run/bare_specifier_without_import/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "run main.ts",
+ "output": "main.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/run/bare_specifier_without_import/main.out b/tests/specs/run/bare_specifier_without_import/main.out
new file mode 100644
index 000000000..a873f2727
--- /dev/null
+++ b/tests/specs/run/bare_specifier_without_import/main.out
@@ -0,0 +1,3 @@
+error: Relative import path "@std/dotenv/load" not prefixed with / or ./ or ../
+ hint: If you want to use a JSR or npm package, try running `deno add @std/dotenv/load`
+ at [WILDCARD]bare_specifier_without_import/main.ts:1:8
diff --git a/tests/specs/run/bare_specifier_without_import/main.ts b/tests/specs/run/bare_specifier_without_import/main.ts
new file mode 100644
index 000000000..67e57b26b
--- /dev/null
+++ b/tests/specs/run/bare_specifier_without_import/main.ts
@@ -0,0 +1,3 @@
+import "@std/dotenv/load";
+
+console.log(Deno.env.get("GREETING")); // hello world