test: fix Vitest runner, 13 smoke tests passing, add tests to CI#248
Conversation
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
|
@DevanshuNEU is attempting to deploy a commit to the Dev's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdded a frontend test execution step to CI, replaced Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
92-98: Consider running tests before the production build step.The
vitest runtest suite operates entirely in the happy-dom environment and does not consume the Vite build output. PlacingRun testsafterBuild frontendmeans:
- A build failure silently prevents test results from appearing in CI.
- Every PR pays the full Vite production-bundle cost (~several seconds) before any test feedback.
Moving the test step before the build (or into its own parallel job) would surface test failures faster and independently:
♻️ Proposed reorder
- name: Install dependencies working-directory: ./frontend run: bun install + - name: Run tests + working-directory: ./frontend + run: bun run test + - name: Build frontend working-directory: ./frontend run: bun run build - - name: Run tests - working-directory: ./frontend - run: bun run test - - name: Check TypeScript working-directory: ./frontend run: bun run tsc --noEmit🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/ci.yml around lines 92 - 98, The CI job currently runs the "Build frontend" step (bun run build) before the "Run tests" step (bun run test); reorder them so the "Run tests" step executes before "Build frontend" (or move "Run tests" into a separate parallel job) to ensure vitest feedback (happy-dom) is produced quickly and independent of Vite build failures—locate the steps named "Build frontend" and "Run tests" in the workflow and swap their order or split into two jobs as appropriate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend/package.json`:
- Line 61: The dependency range for happy-dom in package.json is set to ^20.7.0
which does not exist; update the version spec to the published release (e.g.,
^20.6.0 or 20.6.0) in package.json (the "happy-dom" dependency entry) and also
update the pinned entry in bun.lock to the same existing version so fresh
installs succeed; ensure both files reference the same valid version and run an
install to verify resolution.
In `@frontend/vitest.config.ts`:
- Around line 8-11: The existing comment misstates the environment; update the
comment above the define block so it accurately reflects that
process.env.NODE_ENV is being set to "test" (or state that it forces a
non-production/test mode) to ensure React exposes act() and test utilities;
locate the define object (the 'define' property and 'process.env.NODE_ENV'
assignment) and replace the text "force development mode" with something like
"force test mode (non-production) so React exposes act() and test utilities".
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 92-98: The CI job currently runs the "Build frontend" step (bun
run build) before the "Run tests" step (bun run test); reorder them so the "Run
tests" step executes before "Build frontend" (or move "Run tests" into a
separate parallel job) to ensure vitest feedback (happy-dom) is produced quickly
and independent of Vite build failures—locate the steps named "Build frontend"
and "Run tests" in the workflow and swap their order or split into two jobs as
appropriate.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
What
Fix the test runner and integrate tests into CI pipeline.
Problem
Tests were written (PR #247) but the runner failed with two issues:
Fix
process.env.NODE_ENV = 'test'define in vitest configbun run teststep to CI pipelineTest results
Files changed: 4
Linear
Closes OPE-10
Summary by CodeRabbit