Closed yanick closed 9 months ago
I added the mount
/ unmount
changes to #325 before you made this PR, which will at least unblock the majority of testing. I'm starting to think that either:
rerender
won't be supported in Svelte 5
// comp.test.svelte.js
const props = $state({ name: 'hello' })
render(Comp, { props })
// ...
act(() => (props.name = 'goodbye'))
solid-testing-library
operates$state
ourselves
Either path feels like a bit of a bummer!
* `rerender` won't be supported in Svelte 5 * Instead, the complexity is pushed to the user, who will need to do something like ```js // comp.test.svelte.js const props = $state({ name: 'hello' }) render(Comp, { props }) // ... act(() => (props.name = 'goodbye')) ``` * This is how `solid-testing-library` operates
Yup, that's what I think as well. I'm trying to change the rerender test to use that ^^^ pattern, but for some reason it doesn't react to props.name = 'goodbye'
. But I used a waitFor, not an act, so I'll try that.
* We'll need to introduce a build step into this library so we can use `$state` ourselves
I think we just need to change the name of the test file to be test.svelte.js
for the compiler to do the right thing. I'll say this with more conviction once the test is passing. :-)
Right now my battle plan is
import {} from '@testing-library/svelte
for the latest supported version and import {} from '@testing-library/svelte/svelteX
for X
that are legacy versions and upcoming versions. So yeah, weeeeee, supporting several major versions is fun, fun, fun. :zany_face:
* I actually don't know if this will work
Either path feels like a bit of a bummer!
@mcous This is not the patch we deserve, but probably the patch we need. I'm using the svelte/legacy
API of svelte 5 as I could not make the runes work in the testing context yet. I've also skipped 2 tests for svelte 5 and happy-dom because they are failing in a weird way.
What's the value of it this approach over what's currently in #325, where
pure.js
continues to support both?
import {...} from 'svelte/legacy'
goes boom for Svelte 3 that didn't have that package.
:tada: This PR is included in version 4.2.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
I will! I'm still figuring out how to deal with
$set
. I'll push the code I have right now for shared lulz. It's not yet working, though.