Test environment detection doesn't consider Vitest workspaces
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript, vite
- Domain
- testing-qa
Research direction
Start at src/index.ts lines 213-224 and compare the plugin's test-environment detection with the test.workspace configuration in the linked reproduction. Check that workspace-based environments are respected and that the workaround in vite.config.ts is no longer needed, including avoiding the repeated jsdom installation prompt.
Written by the indexing model from the issue text.
Description
Hello! I am integrating the new Vitest Browser mode into a project using Solid. Their guide suggests that if you want to use it alongside other test environments, you should configure it using workspaces.
The Solid Vite plugin does not appear to read the user test.workspace configuration and defaults to jsdom.
// ...
const userTest = (userConfig as any).test ?? {};
const test = {} as any;
if (userConfig.mode === 'test') {
// ...
if (!userTest.environment && !options.ssr) {
test.environment = 'jsdom';
}
// ...
Which results on being prompted to install jsdom each time
Reproduction
I made a quick reproduction here.
Workaround
My current workaround is to do this on my vite.config.ts:
import { defineConfig } from "vite"
import solid from "vite-plugin-solid"
import tsConfigPaths from "vite-tsconfig-paths"
export default defineConfig({
plugins: [tsConfigPaths(), solid()],
test: {
// Workaround for Solid Vite plugin. Get's superseeded by `workspace` config
environment: "node",
workspace: [
{
extends: true,
test: {
include: ["**/*.test.{ts,tsx}"],
name: "Node.js",
environment: "node",
},
},
{
extends: true,
test: {
include: ["**/*.test.dom.{ts,tsx}"],
browser: {
enabled: true,
headless: true,
ui: false,
provider: "playwright",
instances: [
{
browser: "chromium",
name: "DOM",
},
],
},
},
},
],
},
})
Could the Solid Vite plugin also check the user test.workspace configuration? 🙂 I can draft a PR if the request makes sense
- Dominant language
- TypeScript
- Stars
- 520
- Forks
- 70
- Avg merge
- 23h 35m
- Merged PRs (30d)
- 39
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from solidjs/solid-vite-plugin
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
solidjs/solid-vite-plugin#369 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
solidjs/solid-vite-plugin#328 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
solidjs/solid-vite-plugin#308 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
solidjs/solid-vite-plugin#262 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
solidjs/solid-vite-plugin#259 · 2 comments · 1 reaction ·
All issues in solidjs/solid-vite-plugin
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·