Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

chore: set up test infrastructure for shared packages

Naiyuan Qingb067eee487f9
diff --git a/apps/web/package.json b/apps/web/package.json
index ef5b33e9e8..9f73637410 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -69,15 +69,15 @@
},
"devDependencies": {
"@tailwindcss/postcss": "catalog:",
- "@testing-library/jest-dom": "^6.9.1",
- "@testing-library/react": "^16.3.2",
- "@testing-library/user-event": "^14.6.1",
+ "@testing-library/jest-dom": "catalog:",
+ "@testing-library/react": "catalog:",
+ "@testing-library/user-event": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
- "@vitejs/plugin-react": "^6.0.1",
- "jsdom": "^29.0.1",
+ "@vitejs/plugin-react": "catalog:",
+ "jsdom": "catalog:",
"tailwindcss": "catalog:",
"typescript": "catalog:",
- "vitest": "^4.1.0"
+ "vitest": "catalog:"
}
}
diff --git a/packages/core/package.json b/packages/core/package.json
index db9bfad0a3..4c8524a852 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -5,7 +5,8 @@
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit",
- "lint": "eslint ."
+ "lint": "eslint .",
+ "test": "vitest run"
},
"exports": {
".": "./index.ts",
@@ -64,6 +65,7 @@
"devDependencies": {
"@multica/tsconfig": "workspace:*",
"@types/react": "catalog:",
- "typescript": "catalog:"
+ "typescript": "catalog:",
+ "vitest": "catalog:"
}
}
diff --git a/packages/core/vitest.config.ts b/packages/core/vitest.config.ts
new file mode 100644
index 0000000000..947172e8a8
--- /dev/null
+++ b/packages/core/vitest.config.ts
@@ -0,0 +1,9 @@
+import { defineConfig } from "vitest/config";
+
+export default defineConfig({
+ test: {
+ globals: true,
+ include: ["**/*.test.{ts,tsx}"],
+ passWithNoTests: true,
+ },
+});
diff --git a/packages/views/package.json b/packages/views/package.json
index c21242fd2c..e225ce79af 100644
--- a/packages/views/package.json
+++ b/packages/views/package.json
@@ -5,7 +5,8 @@
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit",
- "lint": "eslint ."
+ "lint": "eslint .",
+ "test": "vitest run"
},
"exports": {
"./navigation": "./navigation/index.ts",
@@ -78,8 +79,14 @@
},
"devDependencies": {
"@multica/tsconfig": "workspace:*",
+ "@testing-library/jest-dom": "catalog:",
+ "@testing-library/react": "catalog:",
+ "@testing-library/user-event": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
- "typescript": "catalog:"
+ "@vitejs/plugin-react": "catalog:",
+ "jsdom": "catalog:",
+ "typescript": "catalog:",
+ "vitest": "catalog:"
}
}
diff --git a/packages/views/test/setup.ts b/packages/views/test/setup.ts
new file mode 100644
index 0000000000..efb4154e31
--- /dev/null
+++ b/packages/views/test/setup.ts
@@ -0,0 +1,16 @@
+import "@testing-library/jest-dom/vitest";
+
+// jsdom doesn't provide ResizeObserver; stub it so components that rely on it
+// (e.g. input-otp) can render in tests.
+if (typeof globalThis.ResizeObserver === "undefined") {
+ globalThis.ResizeObserver = class ResizeObserver {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ } as unknown as typeof ResizeObserver;
+}
+
+// jsdom doesn't implement elementFromPoint; input-otp uses it internally.
+if (typeof document.elementFromPoint !== "function") {
+ document.elementFromPoint = () => null;
+}
diff --git a/packages/views/vitest.config.ts b/packages/views/vitest.config.ts
new file mode 100644
index 0000000000..d48661a415
--- /dev/null
+++ b/packages/views/vitest.config.ts
@@ -0,0 +1,12 @@
+import { defineConfig } from "vitest/config";
+import react from "@vitejs/plugin-react";
+
+export default defineConfig({
+ plugins: [react()],
+ test: {
+ environment: "jsdom",
+ globals: true,
+ setupFiles: ["./test/setup.ts"],
+ include: ["**/*.test.{ts,tsx}"],
+ },
+});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4dec52c9fd..f0dac4e752 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -12,15 +12,30 @@ catalogs:
'@tanstack/react-query':
specifier: ^5.96.2
version: 5.96.2
+ '@testing-library/jest-dom':
+ specifier: ^6.9.1
+ version: 6.9.1
+ '@testing-library/react':
+ specifier: ^16.3.2
+ version: 16.3.2
+ '@testing-library/user-event':
+ specifier: ^14.6.1
+ version: 14.6.1
'@types/node':
specifier: ^25.0.10
version: 25.5.0
+ '@vitejs/plugin-react':
+ specifier: ^6.0.1
+ version: 6.0.1
class-variance-authority:
specifier: ^0.7.1
version: 0.7.1
clsx:
specifier: ^2.1.1
version: 2.1.1
+ jsdom:
+ specifier: ^29.0.1
+ version: 29.0.1
lucide-react:
specifier: ^1.0.1
version: 1.0.1
@@ -39,6 +54,9 @@ catalogs:
typescript:
specifier: ^5.9.3
version: 5.9.3
+ vitest:
+ specifier: ^4.1.0
+ version: 4.1.0
zustand:
specifier: ^5.0.0
version: 5.0.12
@@ -312,13 +330,13 @@ importers:
specifier: 'catalog:'
version: 4.2.2
'@testing-library/jest-dom':
- specifier: ^6.9.1
+ specifier: 'catalog:'
version: 6.9.1
'@testing-library/react':
- specifier: ^16.3.2
+ specifier: 'catalog:'
'@testing-library/user-event':
- specifier: ^14.6.1
+ specifier: 'catalog:'
version: 14.6.1(@testing-library/[email protected])
'@types/react':
specifier: ^19.2.0
@@ -327,10 +345,10 @@ importers:
specifier: ^19.2.0
version: 19.2.3(@types/[email protected])
'@vitejs/plugin-react':
- specifier: ^6.0.1
+ specifier: 'catalog:'
jsdom:
- specifier: ^29.0.1
+ specifier: 'catalog:'
version: 29.0.1(@noble/[email protected])
tailwindcss:
specifier: 'catalog:'
@@ -339,7 +357,7 @@ importers:
specifier: 'catalog:'
version: 5.9.3
vitest:
- specifier: ^4.1.0
+ specifier: 'catalog:'
packages/core:
@@ -366,6 +384,9 @@ importers:
typescript:
specifier: 'catalog:'
version: 5.9.3
+ vitest:
+ specifier: 'catalog:'
packages/eslint-config:
dependencies:
@@ -610,15 +631,33 @@ importers:
'@multica/tsconfig':
specifier: workspace:*
version: link:../tsconfig
+ '@testing-library/jest-dom':
+ specifier: 'catalog:'
+ version: 6.9.1
+ '@testing-library/react':
+ specifier: 'catalog:'
+ '@testing-library/user-event':
+ specifier: 'catalog:'
+ version: 14.6.1(@testing-library/[email protected])
'@types/react':
specifier: ^19.2.0
version: 19.2.14
'@types/react-dom':
specifier: ^19.2.0
version: 19.2.3(@types/[email protected])
+ '@vitejs/plugin-react':
+ specifier: 'catalog:'
+ jsdom:
+ specifier: 'catalog:'
+ version: 29.0.1(@noble/[email protected])
typescript:
specifier: 'catalog:'
version: 5.9.3
+ vitest:
+ specifier: 'catalog:'
packages:
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 0b03b25809..39681b74c8 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -27,3 +27,11 @@ catalog:
# Icons
lucide-react: "^1.0.1"
+
+ # Testing
+ vitest: "^4.1.0"
+ jsdom: "^29.0.1"
+ "@vitejs/plugin-react": "^6.0.1"
+ "@testing-library/react": "^16.3.2"
+ "@testing-library/jest-dom": "^6.9.1"
+ "@testing-library/user-event": "^14.6.1"