Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#1,466 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
javascript
領域
testing

調査の方向性

src/config.js の configure() から始めて、getConfig() が保存された reactStrictMode の値をどのように公開しているかを確認します。reactStrictMode を省略した後続の configure() 呼び出しで以前の設定が保持され、再現手順で説明されている plain-object のケースも含まれるようになれば、修正は完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
JavaScript
スター
19.7k
フォーク
1.2k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

testing-library/react-testing-library のほかの issue

testing-library/react-testing-library の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。