Skip to content

Commit 8eb4bda

Browse files
BojunChaiBojun-Vvibe
authored andcommitted
fix(config): preserve reactStrictMode when only DTL options are configured
Previously, calling configure({testIdAttribute: 'foo'}) destructured reactStrictMode as undefined and overwrote the previously configured value. Only update reactStrictMode when it is actually provided.
1 parent be9d81d commit 8eb4bda

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/__tests__/config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ describe('configuration API', () => {
5656
})
5757
})
5858

59+
test('configuring only DTL options preserves previously set RTL options', () => {
60+
configure({reactStrictMode: true})
61+
configure({testIdAttribute: 'not-data-testid'})
62+
63+
expect(getConfig().reactStrictMode).toBe(true)
64+
expect(getConfig().testIdAttribute).toBe('not-data-testid')
65+
})
66+
5967
test('configure can set DTL and RTL options at once', () => {
6068
const testIdAttribute = 'not-data-testid'
6169
configure({testIdAttribute, reactStrictMode: true})

src/config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ function configure(newConfig) {
2525

2626
configureDTL(configForDTL)
2727

28-
configForRTL = {
29-
...configForRTL,
30-
reactStrictMode,
28+
if (reactStrictMode !== undefined) {
29+
configForRTL = {
30+
...configForRTL,
31+
reactStrictMode,
32+
}
3133
}
3234
}
3335

0 commit comments

Comments
 (0)