repro-64-ui.test.tsx renders framer-motion whileInView without mocking it — emits 'Not implemented: window.scrollTo' and silently skips animation ticks #101

Closed
opened 2026-09-18 04:32:23 +00:00 by Mark · 0 comments
Owner

Where: src/components/workspace/repro-64-ui.test.tsx (no whileInView mock). Compare with issue-66.test.tsx:20, issue-67-context-menu.test.tsx:18, CanvasArea.test.tsx:13 which all mock it.

Repro:

$ npx vitest run src/components/workspace/repro-64-ui.test.tsx --reporter=verbose
✓ repro #64 — RightPanel comboboxes > combobox values persist after Auto-Digitize completes (FAB path)
stderr | src/components/workspace/repro-64-ui.test.tsx > repro #64 — RightPanel comboboxes > ...
Error: Not implemented: window.scrollTo
    at .../jsdom/lib/jsdom/browser/not-implemented.js:9:17
    at .../motion-dom/dist/es/animation/keyframes/KeyframesResolver.mjs:42:24

Reproduced on this session, 2026-09-17. The test still PASSES because
framer-motion swallows the error, but stderr is polluted and the animation
ticks never run — meaning anything that depends on a motion component
resolving to its target state is unverified.

Why this test alone:

Three sibling tests mock framer-motion's whileInView:

vi.mock("framer-motion", async () => {
  const actual = await vi.importActual<typeof import("framer-motion")>("framer-motion");
  return { ...actual, motion: { ...actual.motion, div: actual.div }, whileInView: () => undefined };
});

repro-64-ui.test.tsx renders <RightPanel> (which imports framer-motion
transitively via ToastContainer / CanvasArea) without the same vi.mock.
The component tree reaches a <motion.div whileInView={...}> that calls
window.scrollTo during keyframe measurement under jsdom.

Fix:

Add the same whileInView mock to repro-64-ui.test.tsx that the other
three tests use, OR — better — extract the mock to
src/test/mocks/framer-motion.ts and import it from all four test files.
The latter avoids drift when framer-motion adds new exports that need
stubbing.

Acceptance:

  • npx vitest run src/components/workspace/repro-64-ui.test.tsx emits zero
    Not implemented: window.scrollTo errors.
  • The repro #64 — RightPanel comboboxes test still asserts that combobox
    values (hoop / fabric / stabilizer) survive a full digitize round-trip
    with the FAB Auto-Digitize button.
  • The three sibling tests still pass with the new shared mock.
**Where:** `src/components/workspace/repro-64-ui.test.tsx` (no `whileInView` mock). Compare with `issue-66.test.tsx:20`, `issue-67-context-menu.test.tsx:18`, `CanvasArea.test.tsx:13` which all mock it. **Repro:** ``` $ npx vitest run src/components/workspace/repro-64-ui.test.tsx --reporter=verbose ✓ repro #64 — RightPanel comboboxes > combobox values persist after Auto-Digitize completes (FAB path) stderr | src/components/workspace/repro-64-ui.test.tsx > repro #64 — RightPanel comboboxes > ... Error: Not implemented: window.scrollTo at .../jsdom/lib/jsdom/browser/not-implemented.js:9:17 at .../motion-dom/dist/es/animation/keyframes/KeyframesResolver.mjs:42:24 ``` Reproduced on this session, 2026-09-17. The test still PASSES because framer-motion swallows the error, but stderr is polluted and the animation ticks never run — meaning anything that depends on a motion component resolving to its target state is unverified. **Why this test alone:** Three sibling tests mock `framer-motion`'s `whileInView`: ```ts vi.mock("framer-motion", async () => { const actual = await vi.importActual<typeof import("framer-motion")>("framer-motion"); return { ...actual, motion: { ...actual.motion, div: actual.div }, whileInView: () => undefined }; }); ``` `repro-64-ui.test.tsx` renders `<RightPanel>` (which imports framer-motion transitively via ToastContainer / CanvasArea) without the same `vi.mock`. The component tree reaches a `<motion.div whileInView={...}>` that calls `window.scrollTo` during keyframe measurement under jsdom. **Fix:** Add the same `whileInView` mock to `repro-64-ui.test.tsx` that the other three tests use, OR — better — extract the mock to `src/test/mocks/framer-motion.ts` and import it from all four test files. The latter avoids drift when framer-motion adds new exports that need stubbing. **Acceptance:** - `npx vitest run src/components/workspace/repro-64-ui.test.tsx` emits zero `Not implemented: window.scrollTo` errors. - The `repro #64 — RightPanel comboboxes` test still asserts that combobox values (hoop / fabric / stabilizer) survive a full digitize round-trip with the FAB Auto-Digitize button. - The three sibling tests still pass with the new shared mock.
Mark closed this issue 2026-09-18 05:10:19 +00:00
Sign in to join this conversation.
No description provided.