solidjs / solidjs/solid-vite-plugin
Test environment detection doesn't consider Vitest workspaces
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 520
- Forks
- 70
- Ø Merge
- 23 Std. 35 Min.
- Gemergte PRs (30 T.)
- 39
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne bei den Zeilen 213–224 in src/index.ts und vergleiche die Erkennung der Testumgebung des Plugins mit der test.workspace-Konfiguration in der verknüpften Reproduktion. Überprüfe, dass auf dem Workspace basierende Umgebungen berücksichtigt werden und dass der Workaround in vite.config.ts nicht mehr erforderlich ist, einschließlich der Vermeidung der wiederholten Aufforderung zur Installation von jsdom.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript, vite
- Bereich
- testing-qa
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Aktiv
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 78/100