summaryrefslogtreecommitdiff
path: root/tests/specs/test
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-07-03 20:54:33 -0400
committerGitHub <noreply@github.com>2024-07-04 00:54:33 +0000
commit147411e64b22fe74cb258125acab83f9182c9f81 (patch)
treea1f63dcbf0404c20534986b10f02b649df5a3ad5 /tests/specs/test
parentdd6d19e12051fac2ea5639f621501f4710a1b8e1 (diff)
feat: npm workspace and better Deno workspace support (#24334)
Adds much better support for the unstable Deno workspaces as well as support for npm workspaces. npm workspaces is still lacking in that we only install packages into the root node_modules folder. We'll make it smarter over time in order for it to figure out when to add node_modules folders within packages. This includes a breaking change in config file resolution where we stop searching for config files on the first found package.json unless it's in a workspace. For the previous behaviour, the root deno.json needs to be updated to be a workspace by adding `"workspace": ["./path-to-pkg-json-folder-goes-here"]`. See details in https://github.com/denoland/deno_config/pull/66 Closes #24340 Closes #24159 Closes #24161 Closes #22020 Closes #18546 Closes #16106 Closes #24160
Diffstat (limited to 'tests/specs/test')
-rw-r--r--tests/specs/test/workspace/__test__.jsonc20
-rw-r--r--tests/specs/test/workspace/deno.json6
-rw-r--r--tests/specs/test/workspace/package-a/deno.json5
-rw-r--r--tests/specs/test/workspace/package-a/mod.test.ts7
-rw-r--r--tests/specs/test/workspace/package-a/mod.ts3
-rw-r--r--tests/specs/test/workspace/package-b/deno.json5
-rw-r--r--tests/specs/test/workspace/package-b/mod.test.ts11
-rw-r--r--tests/specs/test/workspace/package-b/mod.ts5
-rw-r--r--tests/specs/test/workspace/package_a.out6
-rw-r--r--tests/specs/test/workspace/package_b.out20
-rw-r--r--tests/specs/test/workspace/root.out23
11 files changed, 111 insertions, 0 deletions
diff --git a/tests/specs/test/workspace/__test__.jsonc b/tests/specs/test/workspace/__test__.jsonc
new file mode 100644
index 000000000..87fd3d46d
--- /dev/null
+++ b/tests/specs/test/workspace/__test__.jsonc
@@ -0,0 +1,20 @@
+{
+ "tests": {
+ "root": {
+ "args": "test",
+ "output": "root.out",
+ "exitCode": 1
+ },
+ "package_a": {
+ "args": "test",
+ "cwd": "package-a",
+ "output": "package_a.out"
+ },
+ "package_b": {
+ "args": "test",
+ "cwd": "package-b",
+ "output": "package_b.out",
+ "exitCode": 1
+ }
+ }
+}
diff --git a/tests/specs/test/workspace/deno.json b/tests/specs/test/workspace/deno.json
new file mode 100644
index 000000000..b72d88442
--- /dev/null
+++ b/tests/specs/test/workspace/deno.json
@@ -0,0 +1,6 @@
+{
+ "workspace": [
+ "./package-a",
+ "./package-b"
+ ]
+}
diff --git a/tests/specs/test/workspace/package-a/deno.json b/tests/specs/test/workspace/package-a/deno.json
new file mode 100644
index 000000000..e6e03ae85
--- /dev/null
+++ b/tests/specs/test/workspace/package-a/deno.json
@@ -0,0 +1,5 @@
+{
+ "name": "@scope/a",
+ "version": "1.0.0",
+ "exports": "./mod.ts"
+}
diff --git a/tests/specs/test/workspace/package-a/mod.test.ts b/tests/specs/test/workspace/package-a/mod.test.ts
new file mode 100644
index 000000000..7ef57fbee
--- /dev/null
+++ b/tests/specs/test/workspace/package-a/mod.test.ts
@@ -0,0 +1,7 @@
+import { add } from "./mod.ts";
+
+Deno.test("add", () => {
+ if (add(1, 2) !== 3) {
+ throw new Error("failed");
+ }
+});
diff --git a/tests/specs/test/workspace/package-a/mod.ts b/tests/specs/test/workspace/package-a/mod.ts
new file mode 100644
index 000000000..8d9b8a22a
--- /dev/null
+++ b/tests/specs/test/workspace/package-a/mod.ts
@@ -0,0 +1,3 @@
+export function add(a: number, b: number): number {
+ return a + b;
+}
diff --git a/tests/specs/test/workspace/package-b/deno.json b/tests/specs/test/workspace/package-b/deno.json
new file mode 100644
index 000000000..f131c191b
--- /dev/null
+++ b/tests/specs/test/workspace/package-b/deno.json
@@ -0,0 +1,5 @@
+{
+ "name": "@scope/b",
+ "version": "1.0.0",
+ "exports": "./mod.ts"
+}
diff --git a/tests/specs/test/workspace/package-b/mod.test.ts b/tests/specs/test/workspace/package-b/mod.test.ts
new file mode 100644
index 000000000..f1499a626
--- /dev/null
+++ b/tests/specs/test/workspace/package-b/mod.test.ts
@@ -0,0 +1,11 @@
+import { addOne } from "./mod.ts";
+
+Deno.test("addOne", () => {
+ if (addOne(1) !== 2) {
+ throw new Error("failed");
+ }
+});
+
+Deno.test("fail", () => {
+ throw new Error("failed");
+});
diff --git a/tests/specs/test/workspace/package-b/mod.ts b/tests/specs/test/workspace/package-b/mod.ts
new file mode 100644
index 000000000..53148ac2f
--- /dev/null
+++ b/tests/specs/test/workspace/package-b/mod.ts
@@ -0,0 +1,5 @@
+import { add } from "@scope/a";
+
+export function addOne(a: number): number {
+ return add(a, 1);
+}
diff --git a/tests/specs/test/workspace/package_a.out b/tests/specs/test/workspace/package_a.out
new file mode 100644
index 000000000..6ebcdfb10
--- /dev/null
+++ b/tests/specs/test/workspace/package_a.out
@@ -0,0 +1,6 @@
+Check file:///[WILDLINE]/package-a/mod.test.ts
+running 1 test from ./mod.test.ts
+add ... ok ([WILDLINE])
+
+ok | 1 passed | 0 failed ([WILDLINE])
+
diff --git a/tests/specs/test/workspace/package_b.out b/tests/specs/test/workspace/package_b.out
new file mode 100644
index 000000000..6c13427ee
--- /dev/null
+++ b/tests/specs/test/workspace/package_b.out
@@ -0,0 +1,20 @@
+Check file:///[WILDLINE]/package-b/mod.test.ts
+running 2 tests from ./mod.test.ts
+addOne ... ok ([WILDLINE])
+fail ... FAILED ([WILDLINE])
+
+ ERRORS
+
+fail => ./mod.test.ts:9:6
+error: Error: failed
+ throw new Error("failed");
+ ^
+ at file:///[WILDLINE]/package-b/mod.test.ts:10:9
+
+ FAILURES
+
+fail => ./mod.test.ts:9:6
+
+FAILED | 1 passed | 1 failed ([WILDLINE])
+
+error: Test failed
diff --git a/tests/specs/test/workspace/root.out b/tests/specs/test/workspace/root.out
new file mode 100644
index 000000000..30bda3ac6
--- /dev/null
+++ b/tests/specs/test/workspace/root.out
@@ -0,0 +1,23 @@
+Check file:///[WILDLINE]/package-a/mod.test.ts
+Check file:///[WILDLINE]/package-b/mod.test.ts
+running 1 test from ./package-a/mod.test.ts
+add ... ok ([WILDLINE])
+running 2 tests from ./package-b/mod.test.ts
+addOne ... ok ([WILDLINE])
+fail ... FAILED ([WILDLINE])
+
+ ERRORS
+
+fail => ./package-b/mod.test.ts:9:6
+error: Error: failed
+ throw new Error("failed");
+ ^
+ at file:///[WILDLINE]/package-b/mod.test.ts:10:9
+
+ FAILURES
+
+fail => ./package-b/mod.test.ts:9:6
+
+FAILED | 2 passed | 1 failed ([WILDLINE])
+
+error: Test failed