sebastianrothe
Do we need to make some changes in this plugin, because of https://github.com/sveltejs/kit/issues/5184 and https://github.com/sveltejs/kit/issues/4329 ?
#16 · closed · 7 comments
Do we need to make some changes in this plugin, because of https://github.com/sveltejs/kit/issues/5184 and https://github.com/sveltejs/kit/issues/4329 ?
I haven't had a chance to take a look yet, but I _think_ we may be able to deprecate this project entirely. My understanding is you would now define a `vite.config.js` file with the `sveltekit` plugin and SvelteKit will use that instead. If you get a chance to check it out soon, please report back! The ideal path IMO would be to deprecate this package entirely, or at least modify if we need to appease Vitest in any way. But generally there are other projects outside of Vitest that also need access to the Vite config so having SvelteKit support it makes the most sense to me.
I wrote a preset [svelte-add-vitest](https://github.com/davipon/svelte-add-vitest), and use `@sveltejs/kit/experimental/vite` under the hood. There is also a new discussion here: https://github.com/sveltejs/kit/discussions/5285
It looks like this project provides [mocks for the `$app` modules](https://github.com/nickbreaton/vitest-svelte-kit/blob/master/packages/vitest-svelte-kit/src/plugins/kit-module-emulator.ts). That's probably the one thing we need to figure out still. SvelteKit will automatically set `$app/env` but others like `$app/stores` are not set until SvelteKit's start function is called, which doesn't happen by just including the Vite plugin. Storybook users [face this as well](https://github.com/storybookjs/storybook/issues/14952). I haven't had the time or experience to think of a solution yet, so I'm open to suggestions!
After playing with Vitest + SvelteKit directly, I'm not seeing a whole lot that isn't working out of the box. @benmccann I can totally see how this may be challenging for Storybook users, but in the context of unit testing I feel any small gaps in functionality can be resolved simply mocking that module. Overall, I feel the experience from a unit test standpoint is very well served by the latest change by SvelteKit to expose itself as a Vite plugin. **Because of this I am going to deprecate this project unless there are any major objections.**
My main thought on the SvelteKit side is whether we can help you in mocking by providing stub objects so you don't have to create the empty objects yourself No objections to ending support here
IMO it would help if theres an instruction to migrate over post-deprecation since the new version actually broke our build recently.
@smblee I can add a little more to the documentation, but the gist of it is: 1. Delete `vitest-svelte-kit` as a dependency 2. Remove your `vitest.config.js` file, Vitest will use the `vite.config.js` file when available 3. Make sure your SvelteKit is up to date and has the `sveltekit` plugin inside of your `vite.config.js` file