summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/lsp_tests.rs4
-rw-r--r--tests/integration/npm_tests.rs4
-rw-r--r--tests/registry/jsr/@denotest/npm-add/0.5.0/mod.ts5
-rw-r--r--tests/registry/jsr/@denotest/npm-add/0.5.0_meta.json5
-rw-r--r--tests/registry/jsr/@denotest/npm-add/1.0.0/mod.ts5
-rw-r--r--tests/registry/jsr/@denotest/npm-add/1.0.0_meta.json5
-rw-r--r--tests/registry/jsr/@denotest/npm-add/meta.json6
-rw-r--r--tests/specs/install/alias_deno_json/__test__.jsonc10
-rw-r--r--tests/specs/install/alias_deno_json/deno.json5
-rw-r--r--tests/specs/install/alias_deno_json/package.json2
-rw-r--r--tests/specs/install/alias_deno_json/verify.ts2
-rw-r--r--tests/specs/install/alias_invalid_path_char/__test__.jsonc10
-rw-r--r--tests/specs/install/alias_invalid_path_char/deno.jsonc7
-rw-r--r--tests/specs/install/alias_invalid_path_char/package.json2
-rw-r--r--tests/specs/install/alias_invalid_path_char/verify.ts10
-rw-r--r--tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/__test__.jsonc10
-rw-r--r--tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/deno.json5
-rw-r--r--tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/package.json5
-rw-r--r--tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/verify.out2
-rw-r--r--tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/verify.ts13
-rw-r--r--tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/__test__.jsonc10
-rw-r--r--tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/deno.json5
-rw-r--r--tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/package.json5
-rw-r--r--tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/verify.out5
-rw-r--r--tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/verify.ts10
-rw-r--r--tests/specs/install/byonm_jsr_npm_dep/__test__.jsonc10
-rw-r--r--tests/specs/install/byonm_jsr_npm_dep/deno.json6
-rw-r--r--tests/specs/install/byonm_jsr_npm_dep/main.ts5
-rw-r--r--tests/specs/install/byonm_jsr_npm_dep/package.json2
-rw-r--r--tests/specs/workspaces/nested_deno_pkg_npm_conflict/__test__.jsonc13
-rw-r--r--tests/specs/workspaces/nested_deno_pkg_npm_conflict/deno.json7
-rw-r--r--tests/specs/workspaces/nested_deno_pkg_npm_conflict/main.js9
-rw-r--r--tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/deno.json5
-rw-r--r--tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/main.js9
34 files changed, 214 insertions, 4 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs
index 4693b7222..4f0f8a985 100644
--- a/tests/integration/lsp_tests.rs
+++ b/tests/integration/lsp_tests.rs
@@ -14797,7 +14797,7 @@ fn lsp_byonm() {
"severity": 1,
"code": "resolver-error",
"source": "deno",
- "message": "Could not find a matching package for 'npm:chalk' in a package.json file. You must specify this as a package.json dependency when the node_modules folder is not managed by Deno.",
+ "message": "Could not find a matching package for 'npm:chalk' in the node_modules directory. Ensure you have all your JSR and npm dependencies listed in your deno.json or package.json, then run `deno install`. Alternatively, turn on auto-install by specifying `\"nodeModulesDir\": \"auto\"` in your deno.json file.",
},
{
"range": {
@@ -14842,7 +14842,7 @@ fn lsp_byonm() {
"severity": 1,
"code": "resolver-error",
"source": "deno",
- "message": "Could not find a matching package for 'npm:chalk' in a package.json file. You must specify this as a package.json dependency when the node_modules folder is not managed by Deno.",
+ "message": "Could not find a matching package for 'npm:chalk' in the node_modules directory. Ensure you have all your JSR and npm dependencies listed in your deno.json or package.json, then run `deno install`. Alternatively, turn on auto-install by specifying `\"nodeModulesDir\": \"auto\"` in your deno.json file.",
},
])
);
diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs
index db63d4533..61ef0b22d 100644
--- a/tests/integration/npm_tests.rs
+++ b/tests/integration/npm_tests.rs
@@ -2195,7 +2195,7 @@ console.log(getKind());
.args("run --allow-read chalk.ts")
.run();
output.assert_matches_text(
- r#"error: Could not find a matching package for 'npm:chalk@5' in a package.json file. You must specify this as a package.json dependency when the node_modules folder is not managed by Deno.
+ r#"error: Could not find a matching package for 'npm:chalk@5' in the node_modules directory. Ensure you have all your JSR and npm dependencies listed in your deno.json or package.json, then run `deno install`. Alternatively, turn on auto-install by specifying `"nodeModulesDir": "auto"` in your deno.json file.
at file:///[WILDCARD]chalk.ts:1:19
"#);
output.assert_exit_code(1);
@@ -2277,7 +2277,7 @@ console.log(getKind());
.args("run --allow-read chalk.ts")
.run();
output.assert_matches_text(
- r#"error: Could not find a matching package for 'npm:chalk@5' in a package.json file. You must specify this as a package.json dependency when the node_modules folder is not managed by Deno.
+ r#"error: Could not find a matching package for 'npm:chalk@5' in the node_modules directory. Ensure you have all your JSR and npm dependencies listed in your deno.json or package.json, then run `deno install`. Alternatively, turn on auto-install by specifying `"nodeModulesDir": "auto"` in your deno.json file.
at file:///[WILDCARD]chalk.ts:1:19
"#);
output.assert_exit_code(1);
diff --git a/tests/registry/jsr/@denotest/npm-add/0.5.0/mod.ts b/tests/registry/jsr/@denotest/npm-add/0.5.0/mod.ts
new file mode 100644
index 000000000..733997e7b
--- /dev/null
+++ b/tests/registry/jsr/@denotest/npm-add/0.5.0/mod.ts
@@ -0,0 +1,5 @@
+import * as npmAdd from "npm:@denotest/add@0.5";
+
+export function sum(a: number, b: number): number {
+ return npmAdd.sum(a, b);
+}
diff --git a/tests/registry/jsr/@denotest/npm-add/0.5.0_meta.json b/tests/registry/jsr/@denotest/npm-add/0.5.0_meta.json
new file mode 100644
index 000000000..631a18d0e
--- /dev/null
+++ b/tests/registry/jsr/@denotest/npm-add/0.5.0_meta.json
@@ -0,0 +1,5 @@
+{
+ "exports": {
+ ".": "./mod.ts"
+ }
+}
diff --git a/tests/registry/jsr/@denotest/npm-add/1.0.0/mod.ts b/tests/registry/jsr/@denotest/npm-add/1.0.0/mod.ts
new file mode 100644
index 000000000..16663bab6
--- /dev/null
+++ b/tests/registry/jsr/@denotest/npm-add/1.0.0/mod.ts
@@ -0,0 +1,5 @@
+import * as npmAdd from "npm:@denotest/add@1";
+
+export function add(a: number, b: number): number {
+ return npmAdd.add(a, b);
+}
diff --git a/tests/registry/jsr/@denotest/npm-add/1.0.0_meta.json b/tests/registry/jsr/@denotest/npm-add/1.0.0_meta.json
new file mode 100644
index 000000000..631a18d0e
--- /dev/null
+++ b/tests/registry/jsr/@denotest/npm-add/1.0.0_meta.json
@@ -0,0 +1,5 @@
+{
+ "exports": {
+ ".": "./mod.ts"
+ }
+}
diff --git a/tests/registry/jsr/@denotest/npm-add/meta.json b/tests/registry/jsr/@denotest/npm-add/meta.json
new file mode 100644
index 000000000..1f9cb6184
--- /dev/null
+++ b/tests/registry/jsr/@denotest/npm-add/meta.json
@@ -0,0 +1,6 @@
+{
+ "versions": {
+ "0.5.0": {},
+ "1.0.0": {}
+ }
+}
diff --git a/tests/specs/install/alias_deno_json/__test__.jsonc b/tests/specs/install/alias_deno_json/__test__.jsonc
new file mode 100644
index 000000000..0398e2eeb
--- /dev/null
+++ b/tests/specs/install/alias_deno_json/__test__.jsonc
@@ -0,0 +1,10 @@
+{
+ "tempDir": true,
+ "steps": [{
+ "args": "install",
+ "output": "[WILDCARD]"
+ }, {
+ "args": "run --allow-read=. verify.ts",
+ "output": "true\n"
+ }]
+}
diff --git a/tests/specs/install/alias_deno_json/deno.json b/tests/specs/install/alias_deno_json/deno.json
new file mode 100644
index 000000000..a1adfb35e
--- /dev/null
+++ b/tests/specs/install/alias_deno_json/deno.json
@@ -0,0 +1,5 @@
+{
+ "imports": {
+ "alias": "npm:@denotest/add"
+ }
+}
diff --git a/tests/specs/install/alias_deno_json/package.json b/tests/specs/install/alias_deno_json/package.json
new file mode 100644
index 000000000..2c63c0851
--- /dev/null
+++ b/tests/specs/install/alias_deno_json/package.json
@@ -0,0 +1,2 @@
+{
+}
diff --git a/tests/specs/install/alias_deno_json/verify.ts b/tests/specs/install/alias_deno_json/verify.ts
new file mode 100644
index 000000000..ea6cadb70
--- /dev/null
+++ b/tests/specs/install/alias_deno_json/verify.ts
@@ -0,0 +1,2 @@
+const stat = Deno.statSync(new URL("./node_modules/alias", import.meta.url));
+console.log(stat.isDirectory);
diff --git a/tests/specs/install/alias_invalid_path_char/__test__.jsonc b/tests/specs/install/alias_invalid_path_char/__test__.jsonc
new file mode 100644
index 000000000..4a3058635
--- /dev/null
+++ b/tests/specs/install/alias_invalid_path_char/__test__.jsonc
@@ -0,0 +1,10 @@
+{
+ "tempDir": true,
+ "steps": [{
+ "args": "install",
+ "output": "[WILDCARD]"
+ }, {
+ "args": "run --allow-read=. verify.ts",
+ "output": ".bin\n.deno\n@denotest\n"
+ }]
+}
diff --git a/tests/specs/install/alias_invalid_path_char/deno.jsonc b/tests/specs/install/alias_invalid_path_char/deno.jsonc
new file mode 100644
index 000000000..85befb55e
--- /dev/null
+++ b/tests/specs/install/alias_invalid_path_char/deno.jsonc
@@ -0,0 +1,7 @@
+{
+ "imports": {
+ // alias*test is an invalid path char on windows, so
+ // don't create an alias for this
+ "alias*test": "npm:@denotest/add"
+ }
+}
diff --git a/tests/specs/install/alias_invalid_path_char/package.json b/tests/specs/install/alias_invalid_path_char/package.json
new file mode 100644
index 000000000..2c63c0851
--- /dev/null
+++ b/tests/specs/install/alias_invalid_path_char/package.json
@@ -0,0 +1,2 @@
+{
+}
diff --git a/tests/specs/install/alias_invalid_path_char/verify.ts b/tests/specs/install/alias_invalid_path_char/verify.ts
new file mode 100644
index 000000000..497e1d8dd
--- /dev/null
+++ b/tests/specs/install/alias_invalid_path_char/verify.ts
@@ -0,0 +1,10 @@
+const entries = Array.from(
+ Deno.readDirSync(new URL("./node_modules", import.meta.url)),
+);
+const names = entries.map((entry) => entry.name);
+names.sort();
+
+// won't have the invalid path alias
+for (const name of names) {
+ console.log(name);
+}
diff --git a/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/__test__.jsonc b/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/__test__.jsonc
new file mode 100644
index 000000000..9a149219d
--- /dev/null
+++ b/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/__test__.jsonc
@@ -0,0 +1,10 @@
+{
+ "tempDir": true,
+ "steps": [{
+ "args": "install",
+ "output": "[WILDCARD]"
+ }, {
+ "args": "run --allow-read=. verify.ts",
+ "output": "verify.out"
+ }]
+}
diff --git a/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/deno.json b/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/deno.json
new file mode 100644
index 000000000..bbd5b9946
--- /dev/null
+++ b/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/deno.json
@@ -0,0 +1,5 @@
+{
+ "imports": {
+ "alias": "jsr:@denotest/add"
+ }
+}
diff --git a/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/package.json b/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/package.json
new file mode 100644
index 000000000..01835ee93
--- /dev/null
+++ b/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/package.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "alias": "npm:@denotest/esm-basic"
+ }
+}
diff --git a/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/verify.out b/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/verify.out
new file mode 100644
index 000000000..dad0ca2d8
--- /dev/null
+++ b/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/verify.out
@@ -0,0 +1,2 @@
+@denotest/esm-basic
+[Module: null prototype] { add: [Function: add] }
diff --git a/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/verify.ts b/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/verify.ts
new file mode 100644
index 000000000..835442322
--- /dev/null
+++ b/tests/specs/install/alias_pkg_json_and_deno_json_jsr_pkg/verify.ts
@@ -0,0 +1,13 @@
+import * as mod from "alias";
+
+const data = JSON.parse(
+ Deno.readTextFileSync(
+ new URL("./node_modules/alias/package.json", import.meta.url),
+ ),
+);
+
+// this should just setup the npm package anyway, even though the alias
+// will resolve to the jsr package
+console.log(data.name);
+
+console.log(mod);
diff --git a/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/__test__.jsonc b/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/__test__.jsonc
new file mode 100644
index 000000000..9a149219d
--- /dev/null
+++ b/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/__test__.jsonc
@@ -0,0 +1,10 @@
+{
+ "tempDir": true,
+ "steps": [{
+ "args": "install",
+ "output": "[WILDCARD]"
+ }, {
+ "args": "run --allow-read=. verify.ts",
+ "output": "verify.out"
+ }]
+}
diff --git a/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/deno.json b/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/deno.json
new file mode 100644
index 000000000..a1adfb35e
--- /dev/null
+++ b/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/deno.json
@@ -0,0 +1,5 @@
+{
+ "imports": {
+ "alias": "npm:@denotest/add"
+ }
+}
diff --git a/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/package.json b/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/package.json
new file mode 100644
index 000000000..01835ee93
--- /dev/null
+++ b/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/package.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "alias": "npm:@denotest/esm-basic"
+ }
+}
diff --git a/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/verify.out b/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/verify.out
new file mode 100644
index 000000000..bc6cb31f7
--- /dev/null
+++ b/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/verify.out
@@ -0,0 +1,5 @@
+@denotest/add
+[Module: null prototype] {
+ add: [Function (anonymous)],
+ default: { add: [Function (anonymous)] }
+}
diff --git a/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/verify.ts b/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/verify.ts
new file mode 100644
index 000000000..bcc0a5d87
--- /dev/null
+++ b/tests/specs/install/alias_pkg_json_and_deno_json_npm_pkg/verify.ts
@@ -0,0 +1,10 @@
+import * as mod from "alias";
+
+const data = JSON.parse(
+ Deno.readTextFileSync(
+ new URL("./node_modules/alias/package.json", import.meta.url),
+ ),
+);
+
+console.log(data.name);
+console.log(mod);
diff --git a/tests/specs/install/byonm_jsr_npm_dep/__test__.jsonc b/tests/specs/install/byonm_jsr_npm_dep/__test__.jsonc
new file mode 100644
index 000000000..ca7064aaf
--- /dev/null
+++ b/tests/specs/install/byonm_jsr_npm_dep/__test__.jsonc
@@ -0,0 +1,10 @@
+{
+ "tempDir": true,
+ "steps": [{
+ "args": "install",
+ "output": "[WILDCARD]"
+ }, {
+ "args": "run main.ts",
+ "output": "3\n4\n"
+ }]
+}
diff --git a/tests/specs/install/byonm_jsr_npm_dep/deno.json b/tests/specs/install/byonm_jsr_npm_dep/deno.json
new file mode 100644
index 000000000..2127bd286
--- /dev/null
+++ b/tests/specs/install/byonm_jsr_npm_dep/deno.json
@@ -0,0 +1,6 @@
+{
+ "imports": {
+ "@denotest/npm-add": "jsr:@denotest/npm-add@1",
+ "@denotest/npm-add-0-5": "jsr:@denotest/npm-add@0.5"
+ }
+}
diff --git a/tests/specs/install/byonm_jsr_npm_dep/main.ts b/tests/specs/install/byonm_jsr_npm_dep/main.ts
new file mode 100644
index 000000000..a75e65bd8
--- /dev/null
+++ b/tests/specs/install/byonm_jsr_npm_dep/main.ts
@@ -0,0 +1,5 @@
+import { add } from "@denotest/npm-add";
+import { sum } from "@denotest/npm-add-0-5";
+
+console.log(add(1, 2));
+console.log(sum(2, 2));
diff --git a/tests/specs/install/byonm_jsr_npm_dep/package.json b/tests/specs/install/byonm_jsr_npm_dep/package.json
new file mode 100644
index 000000000..2c63c0851
--- /dev/null
+++ b/tests/specs/install/byonm_jsr_npm_dep/package.json
@@ -0,0 +1,2 @@
+{
+}
diff --git a/tests/specs/workspaces/nested_deno_pkg_npm_conflict/__test__.jsonc b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/__test__.jsonc
new file mode 100644
index 000000000..1bad68fd4
--- /dev/null
+++ b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/__test__.jsonc
@@ -0,0 +1,13 @@
+{
+ "tempDir": true,
+ "steps": [{
+ "args": "install",
+ "output": "[WILDCARD]"
+ }, {
+ "args": "run --allow-read main.js",
+ "output": "4\n0.5.0\n"
+ }, {
+ "args": "run --allow-read member/main.js",
+ "output": "3\n1.0.0\n"
+ }]
+}
diff --git a/tests/specs/workspaces/nested_deno_pkg_npm_conflict/deno.json b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/deno.json
new file mode 100644
index 000000000..f03a591e2
--- /dev/null
+++ b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/deno.json
@@ -0,0 +1,7 @@
+{
+ "nodeModulesDir": "manual",
+ "workspace": ["./member"],
+ "imports": {
+ "@denotest/add": "npm:@denotest/add@0.5"
+ }
+}
diff --git a/tests/specs/workspaces/nested_deno_pkg_npm_conflict/main.js b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/main.js
new file mode 100644
index 000000000..188da6f97
--- /dev/null
+++ b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/main.js
@@ -0,0 +1,9 @@
+import { sum } from "@denotest/add";
+
+console.log(sum(2, 2));
+
+console.log(
+ JSON.parse(Deno.readTextFileSync(
+ new URL("node_modules/@denotest/add/package.json", import.meta.url),
+ )).version,
+);
diff --git a/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/deno.json b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/deno.json
new file mode 100644
index 000000000..1d36d0aab
--- /dev/null
+++ b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/deno.json
@@ -0,0 +1,5 @@
+{
+ "imports": {
+ "@denotest/add": "npm:@denotest/add@1"
+ }
+}
diff --git a/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/main.js b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/main.js
new file mode 100644
index 000000000..0f64cf553
--- /dev/null
+++ b/tests/specs/workspaces/nested_deno_pkg_npm_conflict/member/main.js
@@ -0,0 +1,9 @@
+import { add } from "@denotest/add";
+
+console.log(add(1, 2));
+
+console.log(
+ JSON.parse(Deno.readTextFileSync(
+ new URL("node_modules/@denotest/add/package.json", import.meta.url),
+ )).version,
+);