test(jsdom): resettable scrollIntoView spy + dedupe matchMedia stub#639
Conversation
Addresses the CodeRabbit nitpick from the (superseded) #623 review on the jsdom test setup that shipped in #636: - scrollIntoView was assigned once as a plain vi.fn(); vi.restoreAllMocks() only restores vi.spyOn spies, so its call history never reset between tests. Ensure a base impl exists, then re-spy each test via vi.spyOn so it resets consistently. - Export installMatchMediaStub and reuse it in accessible-table.dom.test.tsx instead of the copy-pasted local setMatchMedia. Verified: jsdom project 4/4 pass, lint / typecheck / format clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe JSDOM setup now exports a reusable ChangesJSDOM test utilities
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Small follow-up to #636 addressing the one CodeRabbit nitpick (from the now-closed, superseded #623) that applies to code actually on
main— the jsdom test setup.tests/setup/jsdom.setup.ts—scrollIntoViewwas assigned once as a plainvi.fn(), butvi.restoreAllMocks()(afterEach) only restoresvi.spyOnspies, so its call history never reset between tests (a latent isolation gap for any future test asserting onscrollIntoView). Now ensures a base impl exists, then re-spies viavi.spyOn(...).mockImplementation(() => {})eachbeforeEachso it resets consistently. Also exportsinstallMatchMediaStubfor reuse.tests/accessible-table.dom.test.tsx— reuses the sharedinstallMatchMediaStubinstead of a copy-pasted localsetMatchMedia.No behavior change to product code — test-infra only.
Verification
lint,typecheck,format:check— cleanClinical Governance Preflight
N/A — test infrastructure only; no ingestion, answer generation, search, privacy, or clinical output touched.
🤖 Generated with Claude Code
Summary by CodeRabbit