Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Cannot use `dont-cleanup-after-each` in browser

Aperta
#1,131 8 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, react
Ambito
testing-qa

Direzione di ricerca

Inizia esaminando dont-cleanup-after-each.js e la configurazione del browser descritta nell’issue; verifica perché fa riferimento a process quando viene caricato al di fuori di Node. Riproduci il problema in una configurazione di test basata sul browser, quindi conferma che la disabilitazione di cleanup e del comportamento ACT correlato funzioni senza ReferenceError.

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

Descrizione

enhancement
  • @testing-library/react version: 13.3.0
  • Testing Framework and version: Storybook 6.5.9
  • DOM Environment: Browser
Relevant code or config:
import '@testing-library/react/dont-cleanup-after-each';
What you did:

I'm trying to update to react 18, but am getting errors about act not being available in production builds of react. So, I tried setting globalThis.IS_REACT_ACT_ENVIRONMENT = false, but found that this library automatically sets it to true, so to disable it I tried to import dont-cleanup-after-each as instructed in https://testing-library.com/docs/react-testing-library/setup#skipping-auto-cleanup, since https://github.com/testing-library/react-testing-library/pull/994 said to disable it the same way as cleanup.

What happened:
Uncaught ReferenceError: process is not defined
    at dont-cleanup-after-each.js:1:1

This is because process does not exist in browsers, which is where I'm running RTL.

Reproduction:
Problem description:

I can't disable the use of ACT, it seems, which causes my tests to fail.

Suggested solution:

If process is not defined, you could check for import.meta.env and use that instead.

Lingua principale
JavaScript
Stelle
479
Fork
738
Merge medio
5g 1h
PR unite (30g)
2

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 testing-library/testing-library-docs

Tutte le issue di testing-library/testing-library-docs

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.