You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeError: element.animate is not a function
in MyComponent.svelte
in MyComponent.test.svelte
❯ animate ../../node_modules/.pnpm/[email protected]/node_modules/svelte/src/internal/client/dom/elements/transitions.js:377:26
375| // for bidirectional transitions, we start from the current position,
376| // rather than doing a full intro/outro
377| var t1 = counterpart?.t() ?? 1 - t2;
| ^
378| counterpart?.abort();
Svelte transitions now require the web animations API, which is not available in jsdom nor happy-dom, due to their lack of GUI. Since this is internal to Svelte, there's nothing (reasonable) for us to do in svelte-testing-library to resolve this.
If you would like to run component-level tests of transitions, you either need to:
Try to fake out Element.prototype.animate with mock functions (not recommended)
Alternatively, my preferred approach is to move my interesting logic to components and modules that don't involve transitions, test those components, and then pull those into components that only care about the transitions. From there, I don't bother writing additional component tests, because I can trust that Svelte tests its own transition logic
Problem
During migration from Svelte 4 to Svelte 5 I am getting error when I try to render component with
global
transition.If I remove the global transition from
<p in:slide|global>
to<p in:slide>
, it no longer throws any error.Reproduction
Test
Components
Error log
Package versions
The text was updated successfully, but these errors were encountered: