Skip to content

Commit 4e5582a

Browse files
committed
test: fix Vitest runner, all 13 tests passing, add tests to CI
Vitest config fixes: - Switch from jsdom to happy-dom (jsdom 28 has ESM compat issue with html-encoding-sniffer requiring @exodus/bytes) - Add process.env.NODE_ENV='test' define so React exposes act() and testing utilities instead of production build CI pipeline: - Add 'bun run test' step to test-frontend job in ci.yml - Tests now run on every PR alongside build and tsc checks Test results: 3 suites, 13 tests, all passing in 713ms - ErrorBoundary: renders children, shows fallback on error, shows buttons - useGraphData: null handling, orphan filtering, edges, node attrs, layout - useDirectoryMatrix: null handling, dir grouping, cross-dir deps, cycles Closes OPE-10
1 parent abf0925 commit 4e5582a

4 files changed

Lines changed: 29 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ jobs:
9393
working-directory: ./frontend
9494
run: bun run build
9595

96+
- name: Run tests
97+
working-directory: ./frontend
98+
run: bun run test
99+
96100
- name: Check TypeScript
97101
working-directory: ./frontend
98102
run: bun run tsc --noEmit

frontend/bun.lock

Lines changed: 19 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@types/react-dom": "^18.2.17",
5959
"@vitejs/plugin-react": "^4.7.0",
6060
"autoprefixer": "^10.4.16",
61-
"jsdom": "^28.1.0",
61+
"happy-dom": "^20.7.0",
6262
"postcss": "^8.4.32",
6363
"tailwindcss": "^3.4.0",
6464
"typescript": "^5.9.3",

frontend/vitest.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ import path from 'path'
55

66
export default defineConfig({
77
plugins: [react()],
8+
// force development mode so React exposes act() and test utilities
9+
define: {
10+
'process.env.NODE_ENV': '"test"',
11+
},
812
test: {
913
globals: true,
10-
environment: 'jsdom',
14+
environment: 'happy-dom',
1115
setupFiles: ['./src/test/setup.ts'],
1216
include: ['src/**/*.{test,spec}.{ts,tsx}'],
1317
css: false,

0 commit comments

Comments
 (0)