solidjs / solidjs/solid-vite-plugin
Check for `@testing-library/jest-dom` doesn't guarantee it's safe to use as `setupFiles` in Vitest
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 520
- Forks
- 70
- Ø Merge
- 23 Std. 35 Min.
- Gemergte PRs (30 T.)
- 39
Beschreibung
This check doesn't guarantee that passing '@testing-library/jest-dom/vitest' as setupFiles to Vitest is safe.
The current check:
only verifies that eslint-plugin-solid itself can resolve @testing-library/jest-dom/vitest.
It does not guarantee that Vitest can safely use it as a setupFiles entry.
Problem
In my project (using pnpm), I hit a false positive:
storybookdepends directly on@testing-library/jest-dom.storybook-solidjs-vitedepends onvite-plugin-solidvite-plugin-solidlists@testing-library/jest-domas an optional peer dependency.- Because of
pnpm’s virtual store, both end up colocated such thatrequire.resolve("@testing-library/jest-dom/vitest")fromvite-plugin-solidsucceeds.
However, my project itself doesn’t depend on @testing-library/jest-dom, since I only use Vitest with vite-plugin-solid for reactivity tests (no DOM tests).
When Vitest parses the config, it can resolve vite-plugin-solid, but it cannot resolve the automatically added @testing-library/jest-dom/vitest import. This breaks the setup.
Minimal Reproduction
- Create an empty project
pnpm init
pnpm add -D vitest vite vite-plugin-solid
- Add a vitest.config.js with
export default defineConfig({
plugins: [solid()],
test: {
environment: "node",
},
});
And a simple test file (it should run).
- Reinstall dependencies, this time with a transitive dependency on @testing-library/jest-dom:
pnpm add -D storybook storybook-solidjs-vite
- Run the test, it should now fail with "Failed to load url .../@testing-library/jest-dom/vitest".
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
Start with src/index.ts around lines 182-191, then run the pnpm minimal reproduction with Vitest described in the issue. Compare behavior with and without the transitive storybook dependency, and verify that the empty Solid/Vitest project still runs when the package is not a direct dependency.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- testing
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100