solidjs / solidjs/solid-vite-plugin

Test environment detection doesn't consider Vitest workspaces

Aperta Adatta ai principianti
#205 1 commento 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
TypeScript
Stelle
520
Fork
70
Merge medio
23h 35m
PR unite (30g)
39

Descrizione

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

Image

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia alle righe 213-224 di src/index.ts e confronta il rilevamento dell'ambiente di test del plugin con la configurazione test.workspace nella riproduzione collegata. Verifica che gli ambienti basati sul workspace vengano rispettati e che il workaround in vite.config.ts non sia più necessario, evitando anche la richiesta ripetuta di installare jsdom.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript, vite
Ambito
testing-qa
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
78/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.