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 feedback and support #284
Comments
Thank you for this, this works flawlessly, you should def. make a pull request , cheers my friend. |
Thanks @stefanhoelzl, this is working a treat! Any ideas on how to test snippets? So far I haven't managed to figure out how to provide a snippet to the props API. So it's back to the old slots hack of making a wrapping component for tests. |
Anyone have any luck with snippets? The wrapper components are boilerplate-laden - was hoping to not have to do that. If anyone has any pointers, I'm happy to give it a shot myself. |
EDIT: Ignore this part - after a LOT of debugging, this seems to be a problem when using
PrettyFormatPluginError: Cannot read properties of null (reading 'toLowerCase')
|
I've been messing around with Svelte 5 in our existing test suite, and have encountered the following issues so far. I didn't see any of these explicitly called out in the change log, but I'm assuming at the moment that they're all intentional.
|
|
Rudimentary support for Svelte 5 has been released on the
Since Svelte 5 itself is not ready, expect issues and breaking changes if you try it out! |
@mcous thx, so @testing-library/svelte@next is "@testing-library/svelte": "^4.2.0", with this version it works |
FYI for those following along: as of the latest |
:darth vader big NOOO: |
@mcous If you have any suggestions for directed ways to help, I'm all ears :) Though, less familiar with the internals of the lib. Is the issue that they removed the API call we use? And that it needs to be migrated to the new one? Or is the new mount API a no-go? |
Anyone know of any updates? |
Experimental Svelte v5 support is available on the npm install --save-dev @testing-library/svelte@next In your test files: import { render } from '@testing-library/svelte/svelte5' @yanick how would you feel about bumping the The |
Your previous update noted that Svelte 5 support did not work at all. It isn't clear from this update if it has been fixed. |
Fwiw, I'm kinda busy today, but I'll try to turn my attention to deployment tomorrow. |
It has been fixed for now, it may be broken tomorrow. With the very-in-progress nature of Svelte v5, the best way to find out if it's currently working will be to try it yourself |
When I tried testing-lib out a week or so ago, it was working - but also note that there are still bugs depending on whether you're using JSDom vs Happy-Dom, or from svelte itself, or any related libraries. I've been working on a Svelte 5 headless UI port, and Svelte5 + interop is a bit messy at the moment (to say the least) :) |
Experimental Svelte 5 support has landed in
|
When using I have also run into the |
@MatthewTFarley auto-cleanup via plugin works if you use the suggested Svelte 5 alias setup from the README! Otherwise, export default defineConfig({
plugins: [svelte(), svelteTesting()],
test: {
alias: {
'@testing-library/svelte': '@testing-library/svelte/svelte5',
},
},
})
I wonder what's going to happen here! The animations work in the browser, but neither We may have to start thinking about shipping our own |
@mcous I don't know enough to know if what I have should be working, or is expected to be broken. I am on latest versions as of this second of all packages, and latest "next" versions where possible (e.g. Svelte 5 next 118). I have some basic tests working, following the patterns of the internal tests of this actual library ( When I use the alias mentioned above and in the readme, my test suite doesn't run:
My config (after adding the alias):
When I remove the |
@pboling
Both of these jobs the plugin now handles for you. I find that this configuration - as listed in the README - behaves well with Svelte 5: // vite.config.ts
// ...
export default defineConfig({
plugins: [sveltekit(), svelteTesting()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}'],
environment: "jsdom",
alias: {
"@testing-library/svelte": "@testing-library/svelte/svelte5",
},
setupFiles: ["./vitest-setup.ts"],
},
}); // vitest-setup.ts
// Only needed to configure `@testing-library/jest-dom`
import '@testing-library/jest-dom/vitest` If this doesn't work, you could try using a more specific alias. In my own projects, this is necessary only if I'm not using the {
// ...
test: {
// ...
alias: [
{
find: /^@testing-library\/svelte$/,
replacement: '@testing-library/svelte/svelte5',
},
],
// ...
},
} (All this being said, something feels off to me here. I think having a separate Svelte 5 import path is probably causing more trouble than it's worth. I don't think the situation will stick around too much longer, though) |
@mcous The top suggestions you gave are working! I did not need the more specific alternative alias. |
Hello, @mcous has hijacked this post! We've launched experimental Svelte 5 support in
@testing-library/svelte
. See the Svelte 5 section in the README for setup instructions.If you find bugs or have other Svelte 5 testing feedback, please add it to this thread! Svelte 5 is still changing rapidly at the time of writing, so feedback is appreciated!
Original post below
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
@testing-library/svelte@4.0.5
for the project I'm working on to use svelte 5.This patches some breaking changes but there might be more work to do for a proper PR (are tests still working? support svelte 4 and 5, maybe more)
But for everyone who likes to try out svelte 5 this patch should be a good starting point.
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: