diff --git a/apps/portal/package.json b/apps/portal/package.json index 7ba5469280..00a20c4cf6 100644 --- a/apps/portal/package.json +++ b/apps/portal/package.json @@ -44,9 +44,11 @@ "@types/node": "^24.0.3", "eslint": "^9.18.0", "eslint-config-next": "15.5.2", + "jsdom": "^26.1.0", "postcss": "^8.5.4", "tailwindcss": "^4.1.8", - "typescript": "^5.8.3" + "typescript": "^5.8.3", + "vitest": "^3.2.7" }, "peerDependencies": { "react": "^19.1.1", diff --git a/apps/portal/vitest.config.ts b/apps/portal/vitest.config.ts index 5f3f698fd8..1102a058a0 100644 --- a/apps/portal/vitest.config.ts +++ b/apps/portal/vitest.config.ts @@ -1,9 +1,24 @@ +import { resolve } from 'path'; import { defineConfig } from 'vitest/config'; +// No vite plugins on purpose: esbuild already transforms TSX with the automatic +// JSX runtime, and plugin types (e.g. @vitejs/plugin-react, vite-tsconfig-paths) +// can clash with vitest's bundled vite during Next's build-time typecheck on +// Vercel. Aliases are mirrored by hand from tsconfig instead — see +// apps/framework-editor/vitest.config.ts for the same approach. export default defineConfig({ test: { - environment: 'node', + // jsdom, not node: the include glob covers component tests (.jsx/.tsx) that + // need DOM APIs (e.g. testing-library's render). Matches apps/app and + // apps/framework-editor. Node-only tests run fine under jsdom too. + environment: 'jsdom', include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], exclude: ['node_modules', 'dist', '.next'], }, + resolve: { + // Mirror the tsconfig `@/*` path alias so tests can import via `@/...`. + alias: { + '@': resolve(__dirname, './src'), + }, + }, }); diff --git a/bun.lock b/bun.lock index 9428056d21..e95936b8d4 100644 --- a/bun.lock +++ b/bun.lock @@ -487,9 +487,11 @@ "@types/node": "^24.0.3", "eslint": "^9.18.0", "eslint-config-next": "15.5.2", + "jsdom": "^26.1.0", "postcss": "^8.5.4", "tailwindcss": "^4.1.8", "typescript": "^5.8.3", + "vitest": "^3.2.7", }, "peerDependencies": { "react": "^19.1.1",