test(demo): replace the bundle grep with a real single-React test - #208
Conversation
The check added in #203 grepped the minified demo bundle for the repo root's React version string. That is unreliable in both directions: any unrelated occurrence of the version is a false positive, and a duplicate React that happens to match the demo's version is a false negative. It also only ran in CI, so the failure it guards could not be reproduced locally. Replaces it with two tests in examples/, run through examples/vite.config.ts so they exercise the same alias and dedupe as the dev server and the production build. One renders an arrow, the other calls the library's hook from a component the demo compiled. Verified they actually catch the bug: with resolve.dedupe removed both fail with the exact production error, "Cannot read properties of null (reading 'useRef')", and pass with it restored. Also: - examples uses vitest 4, not 3. Importing defineConfig from vitest/config on vitest 3 pulls Vite 7 types alongside @vitejs/plugin-react's Vite 8 and breaks `tsc --noEmit`. vitest 4 accepts Vite 8. - eslint now ignores .worktrees/**. It is gitignored so CI never saw it, but locally eslint walked the built assets inside worktrees and reported 9161 errors. Dropped the now-dead webpack.*.js ignore at the same time. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
✅ Deploy Preview for react-xarrows ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe example project now uses Vitest and Testing Library to test shared React behavior. CI runs the example tests. The previous duplicate-React bundle check was removed, and ESLint now ignores ChangesDemo testing
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/vite.config.ts`:
- Around line 30-33: Add a Vitest setup file for the example tests that imports
cleanup from `@testing-library/react` and afterEach from vitest, then registers
afterEach(cleanup). Reference this setup file from the test configuration near
the existing environment, globals, and include settings so rendered Xarrow and
Xwrapper instances are cleaned up after every test.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 04411491-6f4b-40a9-9321-c7ea2580ced8
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
.github/workflows/ci.ymleslint.config.mjsexamples/package.jsonexamples/src/__tests__/single-react.test.tsxexamples/vite.config.ts
Review feedback on this PR. Testing Library only registers its own cleanup when Vitest exposes afterEach as a global, and this config keeps globals: false, so rendered trees accumulated in the document. That is not only untidy here. Xarrow resolves start and end with document.getElementById, which returns the first match, so a leftover element from an earlier test would be measured instead of the current one. Confirmed with a probe: the second test saw 2 elements with id "from", and 1 after the fix. Re-verified the suite still fails with resolve.dedupe removed, so the added cleanup did not weaken what these tests catch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Follow-up to #203.
The problem with the check that shipped
It greps a minified bundle for a version string, so any unrelated occurrence of
19.2.0is a false positive, and a duplicate React that happens to share the demo's version is a false negative. It is also guarded by[ "$demo_react" != "$root_react" ], so the matching-version case is never checked at all. And it only runs in CI, so the failure it guards cannot be reproduced locally.What replaces it
Two tests in
examples/, run throughexamples/vite.config.tsso they exercise the same alias and dedupe the dev server and production build use:useXarrowfrom a component the demo compiled, which crosses the library/demo boundary even when rendering alone would surviveRoot vitest cannot cover this: it resolves React from the repo root and never goes through the demo's config.
Proof it is not vacuous
With
resolve.deduperemoved, both fail with the exact production error:Restored, both pass. Verified again after the vitest major bump below.
Two incidental fixes
examples uses vitest 4, not 3. Importing
defineConfigfromvitest/configon vitest 3 pulls Vite 7 types alongside@vitejs/plugin-react's Vite 8, which breakstsc --noEmitand thereforeexamplesbuild. vitest 4 accepts Vite 8.eslint now ignores
.worktrees/**. It is gitignored so CI never saw it, but locally eslint walked the built assets inside worktrees and reported 9161 errors, which would hide any real one. Dropped the now-deadwebpack.*.jsignore while there.🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
Chores