Skip to content

test(gui): stub Web Animations API for jsdom - #367

Merged
CameronBrooks11 merged 2 commits into
mainfrom
fix/jsdom-web-animations-stub
Sep 7, 2026
Merged

CameronBrooks11 merged 2 commits into
mainfrom
fix/jsdom-web-animations-stub

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

jsdom implements no Web Animations API. Svelte calls element.animate() when a transition runs, and from 5.57 it does so from a deferred microtask, so the TypeError escapes the test that triggered it and fails the whole run even though every assertion passes.

This is what currently blocks #361 and #363 — both bump svelte 5.56.9 → 5.57.0, and both fail GUI / Test & Build with:

TypeError: element.animate is not a function
 ❯ node_modules/svelte/src/internal/client/dom/elements/transitions.js:415:23
 ❯ run_micro_tasks node_modules/svelte/src/internal/client/dom/task.js:10:2

Note this is not a jsdom bump — jsdom is 30.0.1 on main and on both PRs. Both svelte versions call element.animate; 5.57.0 changed when, moving it into a deferred microtask where the throw is no longer contained.

Fix

An inert Animation in the vitest setup. playState: "finished" stops Svelte's rAF loop immediately, and onfinish is left unfired so transitions stay no-ops rather than half-applying.

Verification

Run against #363's lockfile, varying only the svelte version:

svelte stub result
5.57.0 no red — unhandled TypeError, 339/339 assertions still pass
5.56.9 no green
5.57.0 yes green
5.56.9 yes green

So the stub fixes the failure and is inert on the version main is on today. tsc --noEmit clean; svelte-check 382 files, 0 errors.

jsdom implements no Web Animations API. Svelte calls element.animate()
when a transition runs, and from 5.57 it does so from a deferred
microtask, so the TypeError escapes the test that triggered it and
fails the whole run even though every assertion passes.

Provide an inert Animation in the vitest setup: playState "finished"
stops Svelte's rAF loop immediately, and onfinish is left unfired so
transitions stay no-ops rather than half-applying.

Verified against the lockfile from #363 — red on svelte 5.57.0 without
the stub, green with it, and green either way on the 5.56.9 currently
on main.

Unblocks #361 and #363.
@CameronBrooks11
CameronBrooks11 merged commit 7c80ff0 into main Sep 7, 2026
18 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/jsdom-web-animations-stub branch September 7, 2026 21:35
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