sveltejs / cli

The Svelte CLI
MIT License
258 stars 11 forks source link

feat: `vitest` use client and server side testing for `kit` #311

Open manuel3108 opened 6 days ago

manuel3108 commented 6 days ago

Closes #270

changeset-bot[bot] commented 6 days ago

🦋 Changeset detected

Latest commit: 88f2bdf285ae609d5261f17c961cba8b131fe8c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ---- | ----- | | sv | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

pkg-pr-new[bot] commented 6 days ago

Open in Stackblitz

pnpm add https://pkg.pr.new/sveltejs/cli/sv@311
pnpm add https://pkg.pr.new/sveltejs/cli/svelte-migrate@311

commit: 88f2bdf

manuel3108 commented 6 days ago

The small problem I see here, is that we now have more or less completely different code for vite and kit. But since there is nearly no overlap, i don't think there is a good way around this.

Edit: The original code now in the else is untouched, expect a few comments. Don't know what the diff is doing there.

dominikg commented 6 days ago

requires an update to .gitignore for vitest.workspace temporary bundle files, similar to vite.config and vitest.config

depending on which tsconfig is used, vitest.workspace.ts needs to be added to that too

dominikg commented 6 days ago

also if this is combined with storybook addon and that addon configures vitest for stories with play functions to become tests too, the code needs to be modified differently.

manuel3108 commented 6 days ago

also if this is combined with storybook addon and that addon configures vitest for stories with play functions to become tests too, the code needs to be modified differently.

For storybook we are just executing npx stoybook init. So there is not much we can change on our side. But we can probably get things rolling. Additionally, csf is currently not setup by that cli.

manuel3108 commented 5 days ago

requires an update to .gitignore for vitest.workspace temporary bundle files, similar to vite.config and vitest.config

Does this file get's generated for you? For me i only see vite.config.ts.timestamp-* being generated, even while running pnpm test. Additionally it seems like vite recently merged a PR that's going to generate those files outside of the project root either way. Looks like this will be a change that will be introduced in vite@6

depending on which tsconfig is used, vitest.workspace.ts needs to be added to that too

Why should this be necessary?