Skip to content

test: fix Vitest runner, 13 smoke tests passing, add tests to CI#248

Merged
DevanshuNEU merged 2 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:test/frontend-smoke-tests
Feb 21, 2026
Merged

test: fix Vitest runner, 13 smoke tests passing, add tests to CI#248
DevanshuNEU merged 2 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:test/frontend-smoke-tests

Conversation

@DevanshuNEU

@DevanshuNEU DevanshuNEU commented Feb 21, 2026

Copy link
Copy Markdown
Collaborator

What

Fix the test runner and integrate tests into CI pipeline.

Problem

Tests were written (PR #247) but the runner failed with two issues:

  1. jsdom 28 has ESM compatibility issue (html-encoding-sniffer requires @exodus/bytes as ESM)
  2. React loaded production build which doesn't expose act() for testing

Fix

  • Replaced jsdom with happy-dom (faster, no ESM issues)
  • Added process.env.NODE_ENV = 'test' define in vitest config
  • Added bun run test step to CI pipeline

Test results

3 suites, 13 tests, all passing (713ms)
- ErrorBoundary: 3 tests (render, fallback, buttons)
- useGraphData: 5 tests (null, orphans, edges, attrs, layout)
- useDirectoryMatrix: 5 tests (null, dirs, deps, cycles, labels)

Files changed: 4

  • vitest.config.ts (jsdom -> happy-dom, NODE_ENV define)
  • package.json (jsdom -> happy-dom dep swap)
  • bun.lock
  • .github/workflows/ci.yml (add test step)

Linear

Closes OPE-10

Summary by CodeRabbit

  • Chores
    • Improved testing infrastructure by forcing a consistent test environment and switching to a faster DOM test implementation for more reliable runs.
  • Tests
    • CI now runs frontend tests automatically as part of the build pipeline to catch regressions earlier.

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
@vercel

vercel Bot commented Feb 21, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Feb 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Added a frontend test execution step to CI, replaced jsdom with happy-dom in frontend dependencies, and set process.env.NODE_ENV to "test" in the Vitest configuration.

Changes

Cohort / File(s) Summary
CI Pipeline Configuration
.github/workflows/ci.yml
Inserted a "Run tests" step into the Frontend Tests workflow to run bun run test between frontend build and TypeScript check.
Frontend Testing Dependencies
frontend/package.json
Replaced jsdom devDependency with happy-dom to change the test DOM environment.
Vitest Configuration
frontend/vitest.config.ts
Changed test.environment from jsdom to happy-dom and added define: { 'process.env.NODE_ENV': '"test"' } to force NODE_ENV during tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped into code with a tiny drum,

swapped doms and told NODE_ENV, "You're 'test'!" — chum.
CI now runs my bun-powered spree,
happy-dom cuddles the DOM for me. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: fixing the Vitest runner and integrating tests into CI, which aligns with the primary objectives of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

92-98: Consider running tests before the production build step.

The vitest run test suite operates entirely in the happy-dom environment and does not consume the Vite build output. Placing Run tests after Build frontend means:

  1. A build failure silently prevents test results from appearing in CI.
  2. 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.

Comment thread frontend/package.json
Comment thread frontend/vitest.config.ts Outdated
@vercel

vercel Bot commented Feb 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
opencodeintel Ready Ready Preview, Comment Feb 21, 2026 4:54am

@DevanshuNEU DevanshuNEU merged commit 623a685 into OpenCodeIntel:main Feb 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant