Skip to content

fix: resolve-conditions-for-client #582

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/breezy-clowns-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

fix:addon vitest remove the deprecated `workspace` property in favor of `projects`.
9 changes: 9 additions & 0 deletions .changeset/seven-radios-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'sv': patch
---

fix:addon vitest add resolve.condition.browser to the client
It's fixing the error:
```
`mount(...)` is not available on the server
```
9 changes: 6 additions & 3 deletions packages/addons/vitest-addon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export default defineAddon({
include: common.expressionFromString("['src/**/*.svelte.{test,spec}.{js,ts}']"),
exclude: common.expressionFromString("['src/lib/server/**']"),
setupFiles: common.expressionFromString(`['./vitest-setup-client.${ext}']`)
}),
resolve: object.create({
conditions: common.expressionFromString('["browser"]')
})
});
const serverObjectExpression = object.create({
Expand All @@ -141,9 +144,9 @@ export default defineAddon({
const vitestConfig = functions.argumentByIndex(defineWorkspaceCall, 0, object.createEmpty());
const testObject = object.property(vitestConfig, 'test', object.createEmpty());

const workspaceArray = object.property(testObject, 'workspace', array.createEmpty());
array.push(workspaceArray, clientObjectExpression);
array.push(workspaceArray, serverObjectExpression);
const projectsArray = object.property(testObject, 'projects', array.createEmpty());
array.push(projectsArray, clientObjectExpression);
array.push(projectsArray, serverObjectExpression);

return generateCode();
});
Expand Down