Repository navigation
Open
Labels
Area: SharedCross-tier packages (schemas, react-core, etc.) not covered by another areaArea: Webapps/web (clinician-facing React SPA)ChoreType: maintenance with no user-visible change (dependency upgrades, tooling, tests, refactors)Difficulty: LowIsolated change, about 2 hours or lessPriority: LowNice to have, cosmetic or speculativeUpstreamThe fix belongs in a @douglasneuroinformatics/* package or a third-party dependency
Description
happy-dom is held at ~20.11.15 in the catalog by the dependency update on the deps branch. It provides the environment for the web and react-core vitest projects. The newest release eligible under the repo's 7-day minimumReleaseAge on 2026-10-04 was 20.14.5.
Why it was not upgraded
happy-dom 20.12.0 added the Web Animations API (Element.animate), and motion 13 now detects it and animates through native Animation objects.
- When motion cancels one, happy-dom's
Animation.cancel()rejects thefinishedpromise with anAbortError. - happy-dom leaves that rejection unhandled. The spec marks the cancelled
finishedpromise as handled, so real browsers stay silent.
Under vitest, this produces:
Vitest caught 6 unhandled errors during the test run.
AbortError: The animation was canceled.
❯ Animation.cancel happy-dom@20.14.5/lib/animation/Animation.js:161:32
❯ NativeAnimationExtended.cancel motion-dom@13.4.4/dist/es/animation/NativeAnimation.mjs:75:28
The errors come from CopyButton.test.tsx, InstrumentSummary.test.tsx and ScalarInstrumentRenderer.test.tsx in packages/react-core. Every test passes, but pnpm test exits 1. No matching happy-dom issue was found.
What is required
Either:
- report this to happy-dom, and bump once
cancel()marksfinishedas handled, or - keep motion off native animations in tests, for example by setting
MotionGlobalConfig.skipAnimations = truein a vitest setup file shared bywebandreact-core. There are currently no setup files (apps/web/AGENTS.md), so this would add the first.
Then move the catalog entry back to a caret range and run pnpm test.
Metadata
Metadata
Assignees
Labels
Area: SharedCross-tier packages (schemas, react-core, etc.) not covered by another areaArea: Webapps/web (clinician-facing React SPA)ChoreType: maintenance with no user-visible change (dependency upgrades, tooling, tests, refactors)Difficulty: LowIsolated change, about 2 hours or lessPriority: LowNice to have, cosmetic or speculativeUpstreamThe fix belongs in a @douglasneuroinformatics/* package or a third-party dependency
Activity
joshunrau commentedon Oct 26, 2026
Still applies on
main(d86740e).happy-domis still~20.11.15(pnpm-workspace.yaml:35), and no happy-dom release fixescancel()yet.Upstream
There is already a report, filed before this issue: capricorn86/happy-dom#2339 (2026-09-01). capricorn86/happy-dom#2412 reports the same bug again. The fix is capricorn86/happy-dom#2340, which marks
finishedas handled and replaces it on cancel. All three are open, and the PR has one community approval and no review from the maintainer.lib/animation/Animation.jsis identical in 20.14.6 and 21.0.4 (the latest, 2026-10-20), so a bump alone does not help. There is no date for an upstream fix, so I'd add a test-side workaround now and remove it once capricorn86/happy-dom#2340 ships.Patch happy-dom, not motion
MotionGlobalConfig.skipAnimationscovers less than it looks:motion13.4.4. libui 6.16.1 depends onmotion ^11.18.2, which is installed as a separateframer-motion@11.18.2with its ownMotionGlobalConfig. That copy detects WAAPI the same way (Object.hasOwnProperty.call(Element.prototype, "animate")), and itsAcceleratedAnimation.cancel()cancels the native animation. libui'sCopyButton,NotificationHubandDatePickeranimateopacitythrough it, so they can leak the same error.InstrumentShowcase.test.tsx:96-102turns it on for one suite on purpose.Filtering the error in vitest's
onUnhandledErrorwould also hide a real unawaitedfinishedrejection. The narrower fix is to add the spec step that happy-dom skips:A caller that awaits
finishedstill gets theAbortError, and both motion copies are covered.cancel()is the only place happy-dom rejectsfinished, andElement.animate()constructswindow.Animation, which vitest copies ontoglobalThis. Theeslint-disableis required:@typescript-eslint/unbound-methodis on and flags the destructuring.Plan
Land this after #1660. That PR touches every
vitest.config.ts(Vitest 5, namedbaseConfigexport) andpnpm-workspace.yaml, and adds a bullet directly below the "no setup files" line intesting-strategy.md. It is currentlyCONFLICTING.packages/react-core/src/testing/happy-dom.ts. List it intest.setupFilesinpackages/react-core/vitest.config.tsandapps/web/vitest.config.ts. It needs no coverage exclude, and it imports nothing fromvitest, soodc/test-tooling-in-tests-folderpasses. Leave the other projects out. The ones that opt into happy-dom per file also run node-environment files, which have noAnimation, so the module would throw there.^21.0.3, which already clearsminimumReleaseAge(21.0.4 clears it on 2026-10-27). The only breaking change in 21.0.0 turns CSS and iframe page loading off by default and deprecatesdisableIframePageLoading. Drop that flag and its comment frompackages/react-core/vitest.config.ts:11-13. happy-dom still logs aNotSupportedErrorper iframe, so inpackages/react-core/AGENTS.md:140-142only the sentence about the flag changes. If you'd rather not take the major here,^20.14.6works too. Steps 1 and 2 must land together, because 20.11.15 has noAnimationand the module would throw..agents/docs/architecture/testing-strategy.md:64,apps/web/AGENTS.md:184, and the same comment in six web tests (git grep -n "no vitest setup files"). Their conclusion still holds: RTL won't auto-unmount, because the setup does not callcleanup. Document the setup file in the Tests section ofpackages/react-core/AGENTS.md.Tests
packages/react-core/src/testing/__tests__/happy-dom.test.ts, which runs under the setup file:document.body.animate(...)without readingfinished, wait a macrotask, and assert that aprocess.on('unhandledRejection')listener was not called. This is the test that fails without the patch.finished, cancel, and assert it still rejects withname: 'AbortError'.CopyButton.test.tsx,InstrumentSummary.test.tsxandScalarInstrumentRenderer.test.tsx.pnpm testmust exit 0 withoutVitest caught … unhandled errors.Triage note written with Claude Code. Code references point at
main@d86740e.