bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict mode
まだ誰も着手していません。
評価
- 難易度
- 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 はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
testing-library/react-testing-library のほかの issue
-
fireEvent.select does not wrap its automatic native focus in act対応中かも @sergioperezcheco が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
testing-library/react-testing-library#1459 · コメント 2 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 35/100
testing-library/react-testing-library#1430 · コメント 1 件 ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)対応中かも @swarnim02 が 314 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
testing-library/react-testing-library#1421 · コメント 1 件 ·
testing-library/react-testing-library の issue をすべて見る
似ている issue
-
Engineering
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
techmatters/terraso-web-client#3095 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Service process inherits the caller's cwd at first use, holding that folder open on Windows (EBUSY)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nextcloud/viewer#3424 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信