-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Svelte 5: rendering a component with a global transition causes an error #416
Comments
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:
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 For more context, see various posts in #284: |
An additional workaround could be to simply mock
|
Component tests tend to be fairly highly integrated - your test runs your own code, the Svelte runtime, the browser/fake DOM runtime, etc. all together. For that reason, I strongly recommend against mocking out "third-party" things like the Mocks are best reserved for situations where you completely isolate your code under test with those mocks, which is not possible with component tests |
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: