diff --git a/src/__tests__/config.js b/src/__tests__/config.js index 7fdb1e00..739e081a 100644 --- a/src/__tests__/config.js +++ b/src/__tests__/config.js @@ -54,6 +54,17 @@ describe('configuration API', () => { expect(getConfig().reactStrictMode).toBe(true) }) + + test('configure without reactStrictMode preserves the existing value', () => { + configure({reactStrictMode: true}) + configure({testIdAttribute: 'not-data-testid'}) + + expect(getConfig().reactStrictMode).toBe(true) + + configure({reactStrictMode: false}) + + expect(getConfig().reactStrictMode).toBe(false) + }) }) test('configure can set DTL and RTL options at once', () => { diff --git a/src/config.js b/src/config.js index dc8a5035..0b038e7d 100644 --- a/src/config.js +++ b/src/config.js @@ -27,7 +27,9 @@ function configure(newConfig) { configForRTL = { ...configForRTL, - reactStrictMode, + // Only overwrite the existing value when a new one is provided, + // so calling configure() for other options keeps reactStrictMode. + reactStrictMode: reactStrictMode ?? configForRTL.reactStrictMode, } }