content and assets templates use happy-dom in tests but do not declare it

Aperta Adatta ai principianti
#9,879 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Inizia da templates/content/package.json e templates/assets/package.json, che non hanno una voce happy-dom, e confrontali con templates/mail/package.json, che dichiara happy-dom 20.12.0. Conferma il problema eseguendo pnpm test in un workspace content o assets generato, poi controlla le intestazioni @vitest-environment happy-dom in templates/content/app/root.spec.ts e templates/assets/app/components/FileUploadStorageGate.test.tsx. È completato quando entrambi i template dichiarano la stessa versione di happy-dom di mail e i loro test partono con pnpm test. L'issue suggerisce anche uno script di controllo che confronta gli ambienti di test di ogni template con il rispettivo package.json, ma è facoltativo.

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

Descrizione

Summary
The content and assets templates have test files that start with // @vitest-environment happy-dom, but neither template's package.json declares happy-dom. In a scaffolded workspace nothing else installs it, so those test files fail before running. #8239 fixed this for chat only.

Affected
Upstream main templates content and assets. We hit it on a workspace synced to @agent-native/core 0.231.0.

Evidence

  • templates/content/app/root.spec.ts line 1 and templates/assets/app/components/FileUploadStorageGate.test.tsx line 1: // @vitest-environment happy-dom. Many more in both templates (for example templates/assets/app/routes/home.spec.tsx, templates/content/app/components/ContentCommandSearch.focus.test.tsx).
  • templates/content/package.json and templates/assets/package.json contain no happy-dom or jsdom entry. templates/mail/package.json:100 declares "happy-dom": "20.12.0", and the repo root package.json declares none, so in the monorepo the package is probably found through hoisting from other templates.
  • #8239 describes the same cause for chat. #8331 (open) covers the other installed-workspace test failures, with fix PR #8919, which does not touch package.json of these two templates.

Steps to reproduce

  1. Create a workspace and add the content (or assets) template.
  2. Run pnpm test in that app.
  3. Vitest fails to start the worker: "Cannot find package 'happy-dom'".

Expected
Every template declares the test environments its own tests use, so pnpm test starts in a scaffolded workspace.

Suggested direction
Add happy-dom (same version as mail) to the devDependencies of content and assets. A guard that compares each @vitest-environment in a template to that template's package.json would catch the next one, as suggested in #8239.

Lingua principale
TypeScript
Stelle
7.8k
Fork
715
Merge medio
1g 7h
PR unite (30g)
866

Preparare l'ambiente

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.

Altre issue di BuilderIO/agent-native

Tutte le issue di BuilderIO/agent-native

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.