Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict mode

Offen
#1,466 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

@suhailopensource arbeitet bereits daran.

Seit 29.7.2026.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Ruhig
Tech-Stack
javascript
Bereich
testing

Rechercherichtung

Beginne in src/config.js bei configure() und prüfe anschließend, wie getConfig() den gespeicherten Wert von reactStrictMode bereitstellt. Die Korrektur ist abgeschlossen, wenn ein späterer configure()-Aufruf, der reactStrictMode weglässt, die vorherige Einstellung beibehält, einschließlich des im Reproduktionsbeispiel beschriebenen Falls mit einem Plain Object.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Bug

Calling configure() with any config object that omits reactStrictMode silently resets the previously-configured strict mode flag to undefined.

Root cause

In src/config.js:

function configure(newConfig) {
  if (typeof newConfig === 'function') {
    newConfig = newConfig(getConfig())
  }

  const {reactStrictMode, ...configForDTL} = newConfig

  configureDTL(configForDTL)

  configForRTL = {
    ...configForRTL,
    reactStrictMode,          // <-- always overwrites, even when undefined
  }
}

When newConfig does not include a reactStrictMode key, destructuring yields reactStrictMode = undefined. The spread ...configForRTL correctly carries the previously saved value, but the explicit reactStrictMode property after it overwrites it with undefined.

Reproduction

import { configure, getConfig } from '@testing-library/react'

// Enable strict mode
configure({ reactStrictMode: true })
console.log(getConfig().reactStrictMode)  // true ✓

// Later, an unrelated configure() call — e.g. from a setup file
configure({ asyncUtilTimeout: 2000 })
console.log(getConfig().reactStrictMode)  // undefined ✗  (expected: true)

The second configure() call erases the strict-mode setting. The function-form callback is affected identically:

configure(prev => ({ ...prev, asyncUtilTimeout: 2000 }))
// Works because prev spreads reactStrictMode — but only if callers remember to spread prev.
// The plain-object form has no such safety net.

Impact

Tests that rely on global strict-mode configuration (e.g. set in a setupFilesAfterFramework) silently lose that configuration if any later configure() call omits reactStrictMode. This is particularly easy to hit when test utilities or libraries call configure() with their own options.

Fix

Only write reactStrictMode into configForRTL when it is explicitly present in newConfig:

configForRTL = {
  ...configForRTL,
  ...(reactStrictMode !== undefined && {reactStrictMode}),
}

PR #1461 implements exactly this fix.

Vorherrschende Sprache
JavaScript
Sterne
19.7k
Forks
1.2k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus testing-library/react-testing-library

Alle Issues in testing-library/react-testing-library

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.