diff --git a/packages/react-art/src/__tests__/ReactART-test.js b/packages/react-art/src/__tests__/ReactART-test.js index 063c8df8244c5..b59af8ee02b9d 100644 --- a/packages/react-art/src/__tests__/ReactART-test.js +++ b/packages/react-art/src/__tests__/ReactART-test.js @@ -22,11 +22,21 @@ import Circle from 'react-art/Circle'; import Rectangle from 'react-art/Rectangle'; import Wedge from 'react-art/Wedge'; -let ReactDOMClient; -let act; -let ReactTestRenderer; -let ReactNoop; -let Scheduler; +// Isolate DOM renderer. +jest.resetModules(); + +const ReactDOMClient = require('react-dom/client'); +const act = require('internal-test-utils').act; + +// Isolate test renderer. +jest.resetModules(); +const ReactTestRenderer = require('react-test-renderer'); + +// Isolate the noop renderer +jest.resetModules(); +const ReactNoop = require('react-noop-renderer'); +const Scheduler = require('scheduler'); + let Group; let Shape; let Surface; @@ -63,21 +73,6 @@ describe('ReactART', () => { let container; beforeEach(() => { - // Isolate DOM renderer. - jest.resetModules(); - - ReactDOMClient = require('react-dom/client'); - act = require('internal-test-utils').act; - - // Isolate test renderer. - jest.resetModules(); - ReactTestRenderer = require('react-test-renderer'); - - // Isolate the noop renderer - jest.resetModules(); - ReactNoop = require('react-noop-renderer'); - Scheduler = require('scheduler'); - container = document.createElement('div'); document.body.appendChild(container); diff --git a/packages/react-client/src/__tests__/ReactFlight-test.js b/packages/react-client/src/__tests__/ReactFlight-test.js index 52c127397e6d8..13027da0234af 100644 --- a/packages/react-client/src/__tests__/ReactFlight-test.js +++ b/packages/react-client/src/__tests__/ReactFlight-test.js @@ -42,6 +42,7 @@ let assertLog; describe('ReactFlight', () => { beforeEach(() => { + jest.resetModules(); jest.mock('react', () => require('react/react.react-server')); ReactServer = require('react'); ReactNoopFlightServer = require('react-noop-renderer/flight-server'); diff --git a/packages/react-debug-tools/src/__tests__/ReactDevToolsHooksIntegration-test.js b/packages/react-debug-tools/src/__tests__/ReactDevToolsHooksIntegration-test.js index 695efc7418ad3..eabcbd215bfb2 100644 --- a/packages/react-debug-tools/src/__tests__/ReactDevToolsHooksIntegration-test.js +++ b/packages/react-debug-tools/src/__tests__/ReactDevToolsHooksIntegration-test.js @@ -34,6 +34,8 @@ describe('React hooks DevTools integration', () => { onCommitFiberUnmount: () => {}, }; + jest.resetModules(); + React = require('react'); ReactDebugTools = require('react-debug-tools'); ReactTestRenderer = require('react-test-renderer'); diff --git a/packages/react-debug-tools/src/__tests__/ReactHooksInspection-test.js b/packages/react-debug-tools/src/__tests__/ReactHooksInspection-test.js index 4846a1fb20750..e02debaba101f 100644 --- a/packages/react-debug-tools/src/__tests__/ReactHooksInspection-test.js +++ b/packages/react-debug-tools/src/__tests__/ReactHooksInspection-test.js @@ -15,6 +15,7 @@ let ReactDebugTools; describe('ReactHooksInspection', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDebugTools = require('react-debug-tools'); }); diff --git a/packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js b/packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js index b6224f2dfa76e..076602fed456a 100644 --- a/packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js +++ b/packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js @@ -19,6 +19,7 @@ let useMemoCache; describe('ReactHooksInspectionIntegration', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactTestRenderer = require('react-test-renderer'); ReactDOM = require('react-dom'); diff --git a/packages/react-devtools-shared/src/__tests__/console-test.js b/packages/react-devtools-shared/src/__tests__/console-test.js index 384b28c976858..e8f5376c7bf2e 100644 --- a/packages/react-devtools-shared/src/__tests__/console-test.js +++ b/packages/react-devtools-shared/src/__tests__/console-test.js @@ -924,6 +924,8 @@ describe('console', () => { describe('console error', () => { beforeEach(() => { + jest.resetModules(); + const Console = require('react-devtools-shared/src/backend/console'); patchConsole = Console.patch; unpatchConsole = Console.unpatch; diff --git a/packages/react-devtools-shared/src/hooks/__tests__/parseHookNames-test.js b/packages/react-devtools-shared/src/hooks/__tests__/parseHookNames-test.js index 254a17717fbc4..01135909b5692 100644 --- a/packages/react-devtools-shared/src/hooks/__tests__/parseHookNames-test.js +++ b/packages/react-devtools-shared/src/hooks/__tests__/parseHookNames-test.js @@ -48,6 +48,8 @@ describe('parseHookNames', () => { let parseHookNames; beforeEach(() => { + jest.resetModules(); + jest.mock('source-map-support', () => { console.trace('source-map-support'); }); diff --git a/packages/react-dom/src/__tests__/DOMPropertyOperations-test.js b/packages/react-dom/src/__tests__/DOMPropertyOperations-test.js index 05e1d1234e991..87885ca07b4a5 100644 --- a/packages/react-dom/src/__tests__/DOMPropertyOperations-test.js +++ b/packages/react-dom/src/__tests__/DOMPropertyOperations-test.js @@ -21,6 +21,7 @@ describe('DOMPropertyOperations', () => { let act; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ({act} = require('internal-test-utils')); diff --git a/packages/react-dom/src/__tests__/InvalidEventListeners-test.js b/packages/react-dom/src/__tests__/InvalidEventListeners-test.js index de35dae0f967d..e7c9b5f9610ca 100644 --- a/packages/react-dom/src/__tests__/InvalidEventListeners-test.js +++ b/packages/react-dom/src/__tests__/InvalidEventListeners-test.js @@ -18,6 +18,7 @@ describe('InvalidEventListeners', () => { let container; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; diff --git a/packages/react-dom/src/__tests__/ReactBrowserEventEmitter-test.js b/packages/react-dom/src/__tests__/ReactBrowserEventEmitter-test.js index cf8e5203a5d49..1dd665ce01145 100644 --- a/packages/react-dom/src/__tests__/ReactBrowserEventEmitter-test.js +++ b/packages/react-dom/src/__tests__/ReactBrowserEventEmitter-test.js @@ -45,6 +45,7 @@ let container; // It should probably be rewritten but we're keeping it for some extra coverage. describe('ReactBrowserEventEmitter', () => { beforeEach(() => { + jest.resetModules(); LISTENER.mockClear(); React = require('react'); diff --git a/packages/react-dom/src/__tests__/ReactChildReconciler-test.js b/packages/react-dom/src/__tests__/ReactChildReconciler-test.js index 2e1d9418c8cf8..ef584a7856921 100644 --- a/packages/react-dom/src/__tests__/ReactChildReconciler-test.js +++ b/packages/react-dom/src/__tests__/ReactChildReconciler-test.js @@ -18,6 +18,8 @@ let act; describe('ReactChildReconciler', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; diff --git a/packages/react-dom/src/__tests__/ReactComponent-test.js b/packages/react-dom/src/__tests__/ReactComponent-test.js index 7be43e9cef806..5fa2a4f9f2e6e 100644 --- a/packages/react-dom/src/__tests__/ReactComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactComponent-test.js @@ -17,6 +17,8 @@ let act; describe('ReactComponent', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js index a05e7bd16fc28..4567ee62a0a3e 100644 --- a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js +++ b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js @@ -90,6 +90,8 @@ function getLifeCycleState(instance): ComponentLifeCycle { */ describe('ReactComponentLifeCycle', () => { beforeEach(() => { + jest.resetModules(); + act = require('internal-test-utils').act; React = require('react'); diff --git a/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js b/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js index b478f4fe37e8b..c58e825203f8e 100644 --- a/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js @@ -63,6 +63,7 @@ describe('ReactCompositeComponent', () => { } beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactCompositeComponentState-test.js b/packages/react-dom/src/__tests__/ReactCompositeComponentState-test.js index 299efe1672cd5..a2894b2ca7b27 100644 --- a/packages/react-dom/src/__tests__/ReactCompositeComponentState-test.js +++ b/packages/react-dom/src/__tests__/ReactCompositeComponentState-test.js @@ -520,82 +520,78 @@ describe('ReactCompositeComponent-state', () => { assertLog([ 'render -- step: 3, extra: false', 'callback -- step: 3, extra: false', + + // A second time for the retry. + 'render -- step: 3, extra: false', + 'callback -- step: 3, extra: false', ]); }); - // @gate !disableModulePatternComponents - it('should support stateful module pattern components', async () => { - function Child() { - return { - state: { - count: 123, - }, - render() { - return
{`count:${this.state.count}`}
; - }, - }; - } - - const el = document.createElement('div'); - const root = ReactDOMClient.createRoot(el); - expect(() => { - ReactDOM.flushSync(() => { - root.render(); - }); - }).toErrorDev( - 'Warning: The component appears to be a function component that returns a class instance. ' + - 'Change Child to a class that extends React.Component instead. ' + - "If you can't use a class try assigning the prototype on the function as a workaround. " + - '`Child.prototype = React.Component.prototype`. ' + - "Don't use an arrow function since it cannot be called with `new` by React.", - ); + if (!require('shared/ReactFeatureFlags').disableModulePatternComponents) { + it('should support stateful module pattern components', async () => { + function Child() { + return { + state: { + count: 123, + }, + render() { + return
{`count:${this.state.count}`}
; + }, + }; + } + + const el = document.createElement('div'); + const root = ReactDOMClient.createRoot(el); + expect(() => { + ReactDOM.flushSync(() => { + root.render(); + }); + }).toErrorDev( + 'Warning: The component appears to be a function component that returns a class instance. ' + + 'Change Child to a class that extends React.Component instead. ' + + "If you can't use a class try assigning the prototype on the function as a workaround. " + + '`Child.prototype = React.Component.prototype`. ' + + "Don't use an arrow function since it cannot be called with `new` by React.", + ); - expect(el.textContent).toBe('count:123'); - }); + expect(el.textContent).toBe('count:123'); + }); - // @gate !disableModulePatternComponents - it('should support getDerivedStateFromProps for module pattern components', async () => { - function Child() { - return { - state: { - count: 1, - }, - render() { - return
{`count:${this.state.count}`}
; - }, - }; - } - Child.getDerivedStateFromProps = (props, prevState) => { - return { - count: prevState.count + props.incrementBy, + it('should support getDerivedStateFromProps for module pattern components', async () => { + function Child() { + return { + state: { + count: 1, + }, + render() { + return
{`count:${this.state.count}`}
; + }, + }; + } + Child.getDerivedStateFromProps = (props, prevState) => { + return { + count: prevState.count + props.incrementBy, + }; }; - }; - const el = document.createElement('div'); - const root = ReactDOMClient.createRoot(el); - expect(() => { - ReactDOM.flushSync(() => { + const el = document.createElement('div'); + const root = ReactDOMClient.createRoot(el); + await act(() => { root.render(); }); - }).toErrorDev( - 'Warning: The component appears to be a function component that returns a class instance. ' + - 'Change Child to a class that extends React.Component instead. ' + - "If you can't use a class try assigning the prototype on the function as a workaround. " + - '`Child.prototype = React.Component.prototype`. ' + - "Don't use an arrow function since it cannot be called with `new` by React.", - ); - expect(el.textContent).toBe('count:1'); - await act(() => { - root.render(); - }); - expect(el.textContent).toBe('count:3'); + expect(el.textContent).toBe('count:1'); + await act(() => { + root.render(); + }); + expect(el.textContent).toBe('count:3'); - await act(() => { - root.render(); + await act(() => { + root.render(); + }); + expect(el.textContent).toBe('count:4'); }); - expect(el.textContent).toBe('count:4'); - }); + } it('should not support setState in componentWillUnmount', async () => { let subscription; diff --git a/packages/react-dom/src/__tests__/ReactDOM-test.js b/packages/react-dom/src/__tests__/ReactDOM-test.js index b12226d201d51..00356cc725392 100644 --- a/packages/react-dom/src/__tests__/ReactDOM-test.js +++ b/packages/react-dom/src/__tests__/ReactDOM-test.js @@ -19,6 +19,7 @@ let act; describe('ReactDOM', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMAttribute-test.js b/packages/react-dom/src/__tests__/ReactDOMAttribute-test.js index 0d0dcfa32c7fa..e88bde84826b9 100644 --- a/packages/react-dom/src/__tests__/ReactDOMAttribute-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMAttribute-test.js @@ -15,6 +15,7 @@ describe('ReactDOM unknown attribute', () => { let act; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; diff --git a/packages/react-dom/src/__tests__/ReactDOMComponent-test.js b/packages/react-dom/src/__tests__/ReactDOMComponent-test.js index 3126ef8119bd1..006b29fd97ab3 100644 --- a/packages/react-dom/src/__tests__/ReactDOMComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMComponent-test.js @@ -20,6 +20,7 @@ describe('ReactDOMComponent', () => { let act; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReporting-test.js b/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReporting-test.js index 7072a58acac11..ad5826fe393ea 100644 --- a/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReporting-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReporting-test.js @@ -19,6 +19,7 @@ describe('ReactDOMConsoleErrorReporting', () => { let waitForThrow; beforeEach(() => { + jest.resetModules(); act = require('internal-test-utils').act; React = require('react'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReportingLegacy-test.js b/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReportingLegacy-test.js index 11ad2c99bcb75..bb1e9c83ecf65 100644 --- a/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReportingLegacy-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMConsoleErrorReportingLegacy-test.js @@ -19,6 +19,7 @@ describe('ReactDOMConsoleErrorReporting', () => { let waitForThrow; beforeEach(() => { + jest.resetModules(); act = require('internal-test-utils').act; React = require('react'); ReactDOM = require('react-dom'); diff --git a/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js b/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js index 8a05453848d24..f059d7bd2f560 100644 --- a/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMEventListener-test.js @@ -18,6 +18,7 @@ describe('ReactDOMEventListener', () => { let simulateEventDispatch; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js b/packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js index dbb9409cea268..b90ca9efdb32e 100644 --- a/packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js @@ -18,6 +18,7 @@ describe('ReactDOMEventListener', () => { beforeEach(() => { window.TextEvent = function () {}; + jest.resetModules(); jest.isolateModules(() => { React = require('react'); act = require('internal-test-utils').act; diff --git a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js index 6b9eb722282ce..94172ab77b237 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js @@ -22,6 +22,7 @@ describe('ReactDOMFiber', () => { let container; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); PropTypes = require('prop-types'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzDeferredValue-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzDeferredValue-test.js index 6120a0ef0e2e7..0b3335dfbacb8 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzDeferredValue-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzDeferredValue-test.js @@ -32,6 +32,7 @@ let Suspense; describe('ReactDOMFizzForm', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); Scheduler = require('scheduler'); ReactDOMServer = require('react-dom/server.browser'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzForm-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzForm-test.js index 9385e53b92f6b..ae56c5eae4dd2 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzForm-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzForm-test.js @@ -27,6 +27,7 @@ let useFormState; describe('ReactDOMFizzForm', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMServer = require('react-dom/server.browser'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js index 0e16d217ea150..5a796c5446f06 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js @@ -49,6 +49,7 @@ let streamingContainer; describe('ReactDOMFizzServer', () => { beforeEach(() => { + jest.resetModules(); JSDOM = require('jsdom').JSDOM; const jsdom = new JSDOM( diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js index d3d44a24fe0e5..ab5f8509260df 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js @@ -20,6 +20,7 @@ let Suspense; describe('ReactDOMFizzServerBrowser', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMFizzServer = require('react-dom/server.browser'); Suspense = React.Suspense; diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServerEdge-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServerEdge-test.js index b75fc78716977..c442f1813836c 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzServerEdge-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzServerEdge-test.js @@ -21,6 +21,7 @@ let ReactDOMFizzServer; describe('ReactDOMFizzServerEdge', () => { beforeEach(() => { + jest.resetModules(); jest.useRealTimers(); React = require('react'); ReactDOM = require('react-dom'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServerNode-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServerNode-test.js index 748d9ed7c58d0..f7bab722bb386 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzServerNode-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzServerNode-test.js @@ -17,6 +17,7 @@ let Suspense; describe('ReactDOMFizzServerNode', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMFizzServer = require('react-dom/server'); Stream = require('stream'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js index 8838acfb1e37f..3c2260d83bd6f 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js @@ -27,6 +27,7 @@ let assertLog; describe('ReactDOMFizzShellHydration', () => { beforeEach(() => { + jest.resetModules(); JSDOM = require('jsdom').JSDOM; React = require('react'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzStatic-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzStatic-test.js index 83fcf4a6d131b..49afa26f65e02 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzStatic-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzStatic-test.js @@ -27,6 +27,7 @@ let fatalError = undefined; describe('ReactDOMFizzStatic', () => { beforeEach(() => { + jest.resetModules(); JSDOM = require('jsdom').JSDOM; React = require('react'); ReactDOM = require('react-dom'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js index d063ba798b8ab..7482c7adaac8c 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js @@ -29,6 +29,7 @@ let container; describe('ReactDOMFizzStaticBrowser', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMFizzServer = require('react-dom/server.browser'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzStaticFloat-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzStaticFloat-test.js index eafe097f9b871..9a825bf1e3871 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzStaticFloat-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzStaticFloat-test.js @@ -28,6 +28,7 @@ let container; describe('ReactDOMFizzStaticFloat', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMFizzServer = require('react-dom/server.browser'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzStaticNode-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzStaticNode-test.js index c22c688432775..a049ec4c49222 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzStaticNode-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzStaticNode-test.js @@ -16,6 +16,7 @@ let Suspense; describe('ReactDOMFizzStaticNode', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); if (__EXPERIMENTAL__) { ReactDOMFizzStatic = require('react-dom/static'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzSuppressHydrationWarning-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzSuppressHydrationWarning-test.js index 7c145dc145d7e..3300297b77ee0 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzSuppressHydrationWarning-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzSuppressHydrationWarning-test.js @@ -26,6 +26,7 @@ let waitForAll; describe('ReactDOMFizzServerHydrationWarning', () => { beforeEach(() => { + jest.resetModules(); JSDOM = require('jsdom').JSDOM; Scheduler = require('scheduler'); React = require('react'); diff --git a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js index 8ab5e1db04680..eaad571ad9759 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFloat-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFloat-test.js @@ -40,6 +40,7 @@ let streamingContainer; describe('ReactDOMFloat', () => { beforeEach(() => { + jest.resetModules(); JSDOM = require('jsdom').JSDOM; const jsdom = new JSDOM( diff --git a/packages/react-dom/src/__tests__/ReactDOMForm-test.js b/packages/react-dom/src/__tests__/ReactDOMForm-test.js index 9d2e37f49db5e..795909b6eaf46 100644 --- a/packages/react-dom/src/__tests__/ReactDOMForm-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMForm-test.js @@ -44,6 +44,7 @@ describe('ReactDOMForm', () => { let useFormState; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMHooks-test.js b/packages/react-dom/src/__tests__/ReactDOMHooks-test.js index ccf555a4f9b14..ad8fadad1ff97 100644 --- a/packages/react-dom/src/__tests__/ReactDOMHooks-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMHooks-test.js @@ -19,6 +19,8 @@ describe('ReactDOMHooks', () => { let container; beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js b/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js index ff150066f9a1b..76a8229e5a89f 100644 --- a/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js @@ -21,6 +21,7 @@ describe('ReactDOMServerHydration', () => { let container; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMInReactServer-test.js b/packages/react-dom/src/__tests__/ReactDOMInReactServer-test.js index f1067ef3d4922..f3bc6ea8aded2 100644 --- a/packages/react-dom/src/__tests__/ReactDOMInReactServer-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMInReactServer-test.js @@ -11,6 +11,7 @@ describe('ReactDOMInReactServer', () => { beforeEach(() => { + jest.resetModules(); jest.mock('react', () => require('react/react.react-server')); }); diff --git a/packages/react-dom/src/__tests__/ReactDOMInput-test.js b/packages/react-dom/src/__tests__/ReactDOMInput-test.js index dc9456bc8bb72..2ccd1c043661a 100644 --- a/packages/react-dom/src/__tests__/ReactDOMInput-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMInput-test.js @@ -79,6 +79,8 @@ describe('ReactDOMInput', () => { } beforeEach(() => { + jest.resetModules(); + setUntrackedValue = Object.getOwnPropertyDescriptor( HTMLInputElement.prototype, 'value', diff --git a/packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js b/packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js index ca262e28b7e44..1768ec14ea9e0 100644 --- a/packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js @@ -16,6 +16,7 @@ describe('ReactDOMInvalidARIAHook', () => { let act; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; diff --git a/packages/react-dom/src/__tests__/ReactDOMLegacyFloat-test.js b/packages/react-dom/src/__tests__/ReactDOMLegacyFloat-test.js index f05dd4a444198..94876e41641f9 100644 --- a/packages/react-dom/src/__tests__/ReactDOMLegacyFloat-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMLegacyFloat-test.js @@ -15,6 +15,8 @@ let ReactDOMFizzServer; describe('ReactDOMFloat', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOMFizzServer = require('react-dom/server'); }); diff --git a/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js b/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js index c549af0cee062..6b445f9cf8d61 100644 --- a/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js @@ -22,6 +22,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => { let container; beforeEach(() => { + jest.resetModules(); container = document.createElement('div'); React = require('react'); ReactDOM = require('react-dom'); diff --git a/packages/react-dom/src/__tests__/ReactDOMNestedEvents-test.js b/packages/react-dom/src/__tests__/ReactDOMNestedEvents-test.js index 89841f7ef955d..f7b0db175e5f6 100644 --- a/packages/react-dom/src/__tests__/ReactDOMNestedEvents-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMNestedEvents-test.js @@ -18,6 +18,7 @@ describe('ReactDOMNestedEvents', () => { let assertLog; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); Scheduler = require('scheduler'); diff --git a/packages/react-dom/src/__tests__/ReactDOMOption-test.js b/packages/react-dom/src/__tests__/ReactDOMOption-test.js index 8d6849e32ec7a..c0597c36b20d1 100644 --- a/packages/react-dom/src/__tests__/ReactDOMOption-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMOption-test.js @@ -17,6 +17,7 @@ describe('ReactDOMOption', () => { let act; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMRoot-test.js b/packages/react-dom/src/__tests__/ReactDOMRoot-test.js index 8453150a38a35..7967cf84a2672 100644 --- a/packages/react-dom/src/__tests__/ReactDOMRoot-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMRoot-test.js @@ -24,6 +24,7 @@ describe('ReactDOMRoot', () => { let container; beforeEach(() => { + jest.resetModules(); container = document.createElement('div'); React = require('react'); ReactDOM = require('react-dom'); diff --git a/packages/react-dom/src/__tests__/ReactDOMSafariMicrotaskBug-test.js b/packages/react-dom/src/__tests__/ReactDOMSafariMicrotaskBug-test.js index b137ead3c34a1..17b1aed89ce72 100644 --- a/packages/react-dom/src/__tests__/ReactDOMSafariMicrotaskBug-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMSafariMicrotaskBug-test.js @@ -43,6 +43,7 @@ describe('ReactDOMSafariMicrotaskBug-test', () => { } }; + jest.resetModules(); container = document.createElement('div'); React = require('react'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMSelect-test.js b/packages/react-dom/src/__tests__/ReactDOMSelect-test.js index c61289011d6ae..35aaba29a6a46 100644 --- a/packages/react-dom/src/__tests__/ReactDOMSelect-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMSelect-test.js @@ -26,6 +26,7 @@ describe('ReactDOMSelect', () => { const noop = function () {}; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js index 1acbda0c29177..bda021b5e06a7 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js @@ -20,6 +20,8 @@ let ReactTestUtils; let ReactDOMServer; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationBasic-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationBasic-test.js index 25a443da7d55e..2821dd088bb48 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationBasic-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationBasic-test.js @@ -20,6 +20,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationCheckbox-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationCheckbox-test.js index bfc6d410bfaa0..178ed7982a44f 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationCheckbox-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationCheckbox-test.js @@ -20,6 +20,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationClassContextType-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationClassContextType-test.js index 28db8815550f7..2df2d66b9b9fa 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationClassContextType-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationClassContextType-test.js @@ -18,6 +18,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js index 2e1f419ca945f..ea30b45e3d61c 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js @@ -22,6 +22,7 @@ let ReactFeatureFlags; let ReactTestUtils; function initModules() { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationFragment-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationFragment-test.js index 586fe8b016e82..8e8fc2aa8fe27 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationFragment-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationFragment-test.js @@ -18,6 +18,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js index 6f42b23ca9fcc..7e46bea5f93d9 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js @@ -35,6 +35,9 @@ let yieldValue; let clearLog; function initModules() { + // Reset warning cache. + jest.resetModules(); + React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationInput-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationInput-test.js index 4dfc3628f749d..54780dae52cdb 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationInput-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationInput-test.js @@ -20,6 +20,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js index a9594872155e0..1481fcd326bb0 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContext-test.js @@ -19,6 +19,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); PropTypes = require('prop-types'); React = require('react'); ReactDOM = require('react-dom'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationModes-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationModes-test.js index 2ea05bd56ed36..99cf33b821f17 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationModes-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationModes-test.js @@ -18,6 +18,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js index a460e2104ce88..bd4797f9ef146 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js @@ -18,6 +18,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationReconnecting-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationReconnecting-test.js index 5329a419d4283..76612f510d7d2 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationReconnecting-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationReconnecting-test.js @@ -19,6 +19,9 @@ let ReactTestUtils; describe('ReactDOMServerIntegration', () => { function initModules() { + // Reset warning cache. + jest.resetModules(); + React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); @@ -456,6 +459,9 @@ describe('ReactDOMServerIntegration', () => { describe('ReactDOMServerIntegration (legacy)', () => { function initModules() { + // Reset warning cache. + jest.resetModules(); + React = require('react'); ReactDOM = require('react-dom'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationRefs-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationRefs-test.js index d14b38f3dcb8f..e5564d3d9348c 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationRefs-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationRefs-test.js @@ -17,6 +17,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js index bc55cf89232ee..9e503be7520b2 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSelect-test.js @@ -18,6 +18,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSpecialTypes-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSpecialTypes-test.js index 94336a7611c67..8ea1c9d53baee 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSpecialTypes-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationSpecialTypes-test.js @@ -23,6 +23,8 @@ let log; let clearLog; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationTextarea-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationTextarea-test.js index 07e65b7eabdb2..dd19385e62c56 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationTextarea-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationTextarea-test.js @@ -18,6 +18,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.js index f0780da48a628..55336a2cb5636 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.js @@ -32,6 +32,7 @@ describe('ReactDOMServerIntegration - Untrusted URLs', () => { } function initModules() { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); @@ -196,6 +197,7 @@ describe('ReactDOMServerIntegration - Untrusted URLs - disableJavaScriptURLs', ( } function initModules() { + jest.resetModules(); const ReactFeatureFlags = require('shared/ReactFeatureFlags'); ReactFeatureFlags.disableJavaScriptURLs = true; diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js index 5d6abf288d2ba..bc5980f23dda2 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUserInteraction-test.js @@ -17,6 +17,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerLifecycles-test.js b/packages/react-dom/src/__tests__/ReactDOMServerLifecycles-test.js index 53999c560c25f..8b3ea97816427 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerLifecycles-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerLifecycles-test.js @@ -15,6 +15,8 @@ let React; let ReactDOMServer; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMShorthandCSSPropertyCollision-test.js b/packages/react-dom/src/__tests__/ReactDOMShorthandCSSPropertyCollision-test.js index 7cd7c77b0fea7..b04bbb0ab4eb3 100644 --- a/packages/react-dom/src/__tests__/ReactDOMShorthandCSSPropertyCollision-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMShorthandCSSPropertyCollision-test.js @@ -16,6 +16,8 @@ describe('ReactDOMShorthandCSSPropertyCollision', () => { let ReactDOMClient; beforeEach(() => { + jest.resetModules(); + act = require('internal-test-utils').act; React = require('react'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMSingletonComponents-test.js b/packages/react-dom/src/__tests__/ReactDOMSingletonComponents-test.js index 65bc8a830dd3e..9c4c3fc913be1 100644 --- a/packages/react-dom/src/__tests__/ReactDOMSingletonComponents-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMSingletonComponents-test.js @@ -26,6 +26,7 @@ let waitForAll; describe('ReactDOM HostSingleton', () => { beforeEach(() => { + jest.resetModules(); JSDOM = require('jsdom').JSDOM; React = require('react'); ReactDOM = require('react-dom'); diff --git a/packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js b/packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js index 1f655eee2ed4e..537e448f86dd8 100644 --- a/packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js @@ -21,6 +21,7 @@ describe('ReactDOMSuspensePlaceholder', () => { let container; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.js b/packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.js index c194b8184b964..65bb49e06a1c8 100644 --- a/packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.js @@ -27,7 +27,10 @@ describe('ReactDOMTestSelectors', () => { let container; beforeEach(() => { + jest.resetModules(); + React = require('react'); + act = require('internal-test-utils').act; if (__EXPERIMENTAL__ || global.__WWW__) { diff --git a/packages/react-dom/src/__tests__/ReactDOMTextarea-test.js b/packages/react-dom/src/__tests__/ReactDOMTextarea-test.js index 74b46850911aa..3d21ca64e399e 100644 --- a/packages/react-dom/src/__tests__/ReactDOMTextarea-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMTextarea-test.js @@ -22,6 +22,8 @@ describe('ReactDOMTextarea', () => { const ReactFeatureFlags = require('shared/ReactFeatureFlags'); beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDOMserverIntegrationProgress-test.js b/packages/react-dom/src/__tests__/ReactDOMserverIntegrationProgress-test.js index 1a64e54d6f37e..cf51eff4aced3 100644 --- a/packages/react-dom/src/__tests__/ReactDOMserverIntegrationProgress-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMserverIntegrationProgress-test.js @@ -18,6 +18,8 @@ let ReactDOMServer; let ReactTestUtils; function initModules() { + // Reset warning cache. + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactDeprecationWarnings-test.js b/packages/react-dom/src/__tests__/ReactDeprecationWarnings-test.js index efb66e7a4fbfc..4c6a0bed84a6c 100644 --- a/packages/react-dom/src/__tests__/ReactDeprecationWarnings-test.js +++ b/packages/react-dom/src/__tests__/ReactDeprecationWarnings-test.js @@ -16,6 +16,7 @@ let waitForAll; describe('ReactDeprecationWarnings', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); const InternalTestUtils = require('internal-test-utils'); diff --git a/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js b/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js index c2586a4d2a237..9316ad4392f61 100644 --- a/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js @@ -21,6 +21,8 @@ let container; describe('ReactEmptyComponent', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactEventIndependence-test.js b/packages/react-dom/src/__tests__/ReactEventIndependence-test.js index 085f07bbed98c..05cbca61752f6 100644 --- a/packages/react-dom/src/__tests__/ReactEventIndependence-test.js +++ b/packages/react-dom/src/__tests__/ReactEventIndependence-test.js @@ -15,6 +15,8 @@ let act; describe('ReactEventIndependence', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; diff --git a/packages/react-dom/src/__tests__/ReactFunctionComponent-test.js b/packages/react-dom/src/__tests__/ReactFunctionComponent-test.js index fffca3675a711..2d04c4af90937 100644 --- a/packages/react-dom/src/__tests__/ReactFunctionComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactFunctionComponent-test.js @@ -21,6 +21,7 @@ function FunctionComponent(props) { describe('ReactFunctionComponent', () => { beforeEach(() => { + jest.resetModules(); PropTypes = require('prop-types'); React = require('react'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactIdentity-test.js b/packages/react-dom/src/__tests__/ReactIdentity-test.js index 98e8e0533cecb..5c25daf7d8f30 100644 --- a/packages/react-dom/src/__tests__/ReactIdentity-test.js +++ b/packages/react-dom/src/__tests__/ReactIdentity-test.js @@ -16,6 +16,7 @@ let act; describe('ReactIdentity', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactTestUtils = require('react-dom/test-utils'); diff --git a/packages/react-dom/src/__tests__/ReactLegacyCompositeComponent-test.js b/packages/react-dom/src/__tests__/ReactLegacyCompositeComponent-test.js index 96629906f7cf5..42908a693cce3 100644 --- a/packages/react-dom/src/__tests__/ReactLegacyCompositeComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactLegacyCompositeComponent-test.js @@ -17,6 +17,7 @@ let act; describe('ReactLegacyCompositeComponent', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactLegacyMount-test.js b/packages/react-dom/src/__tests__/ReactLegacyMount-test.js index d33325bd4dd98..78492811428c3 100644 --- a/packages/react-dom/src/__tests__/ReactLegacyMount-test.js +++ b/packages/react-dom/src/__tests__/ReactLegacyMount-test.js @@ -22,6 +22,8 @@ let waitForAll; describe('ReactMount', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactLegacyRootWarnings-test.js b/packages/react-dom/src/__tests__/ReactLegacyRootWarnings-test.js index 23da335dce0e0..9504de2c0a97e 100644 --- a/packages/react-dom/src/__tests__/ReactLegacyRootWarnings-test.js +++ b/packages/react-dom/src/__tests__/ReactLegacyRootWarnings-test.js @@ -4,6 +4,7 @@ describe('ReactDOMRoot', () => { let container; beforeEach(() => { + jest.resetModules(); container = document.createElement('div'); ReactDOM = require('react-dom'); }); diff --git a/packages/react-dom/src/__tests__/ReactLegacyUpdates-test.js b/packages/react-dom/src/__tests__/ReactLegacyUpdates-test.js index 462e90f2c04ca..d1e54dbb055ca 100644 --- a/packages/react-dom/src/__tests__/ReactLegacyUpdates-test.js +++ b/packages/react-dom/src/__tests__/ReactLegacyUpdates-test.js @@ -20,6 +20,7 @@ let assertLog; // Can be deleted when we remove both. describe('ReactLegacyUpdates', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactTestUtils = require('react-dom/test-utils'); diff --git a/packages/react-dom/src/__tests__/ReactMultiChild-test.js b/packages/react-dom/src/__tests__/ReactMultiChild-test.js index cf31e0914547f..96413378f6aef 100644 --- a/packages/react-dom/src/__tests__/ReactMultiChild-test.js +++ b/packages/react-dom/src/__tests__/ReactMultiChild-test.js @@ -15,6 +15,7 @@ describe('ReactMultiChild', () => { let act; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; diff --git a/packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js b/packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js index 1c10335e9b524..3a2a5126882ce 100644 --- a/packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js +++ b/packages/react-dom/src/__tests__/ReactMultiChildReconcile-test.js @@ -304,6 +304,10 @@ async function testPropsSequence(sequence) { } describe('ReactMultiChildReconcile', () => { + beforeEach(() => { + jest.resetModules(); + }); + it('should reset internal state if removed then readded in an array', async () => { // Test basics. const props = { diff --git a/packages/react-dom/src/__tests__/ReactRenderDocument-test.js b/packages/react-dom/src/__tests__/ReactRenderDocument-test.js index e828889995ed4..3eab0e6c3661b 100644 --- a/packages/react-dom/src/__tests__/ReactRenderDocument-test.js +++ b/packages/react-dom/src/__tests__/ReactRenderDocument-test.js @@ -30,6 +30,8 @@ function getTestDocument(markup) { describe('rendering React components at document', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactServerRendering-test.js b/packages/react-dom/src/__tests__/ReactServerRendering-test.js index b95c20f9e3182..3b398a47feb28 100644 --- a/packages/react-dom/src/__tests__/ReactServerRendering-test.js +++ b/packages/react-dom/src/__tests__/ReactServerRendering-test.js @@ -17,6 +17,7 @@ let ReactCurrentDispatcher; describe('ReactDOMServer', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); PropTypes = require('prop-types'); ReactDOMServer = require('react-dom/server'); diff --git a/packages/react-dom/src/__tests__/ReactServerRenderingBrowser-test.js b/packages/react-dom/src/__tests__/ReactServerRenderingBrowser-test.js index 375e12ec176b9..e99bc4904d1e4 100644 --- a/packages/react-dom/src/__tests__/ReactServerRenderingBrowser-test.js +++ b/packages/react-dom/src/__tests__/ReactServerRenderingBrowser-test.js @@ -16,6 +16,7 @@ let ReactDOMServerBrowser; describe('ReactServerRenderingBrowser', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMServer = require('react-dom/server'); // For extra isolation between what would be two bundles on npm diff --git a/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js b/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js index 1b054e6530c89..c7416b255d471 100644 --- a/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js +++ b/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js @@ -22,6 +22,7 @@ let act; // If a test only needs ReactDOMServer, put it in ReactServerRendering-test instead. describe('ReactDOMServerHydration', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js b/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js index b7f4890fac9d1..9f24801907ba1 100644 --- a/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js +++ b/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js @@ -81,6 +81,7 @@ describe('ReactTestUtils.act()', () => { function runActTests(render, unmount, rerender) { describe('concurrent render', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactTestUtils = require('react-dom/test-utils'); diff --git a/packages/react-dom/src/__tests__/ReactTestUtilsActUnmockedScheduler-test.js b/packages/react-dom/src/__tests__/ReactTestUtilsActUnmockedScheduler-test.js index 618317dab8e04..45babfd4032d3 100644 --- a/packages/react-dom/src/__tests__/ReactTestUtilsActUnmockedScheduler-test.js +++ b/packages/react-dom/src/__tests__/ReactTestUtilsActUnmockedScheduler-test.js @@ -27,6 +27,7 @@ function clearLog() { beforeEach(() => { prevActGlobal = global.IS_REACT_ACT_ENVIRONMENT; global.IS_REACT_ACT_ENVIRONMENT = true; + jest.resetModules(); jest.unmock('scheduler'); yields = []; React = require('react'); diff --git a/packages/react-dom/src/__tests__/ReactUpdates-test.js b/packages/react-dom/src/__tests__/ReactUpdates-test.js index cf6d0ccb9ecde..ea4d8480c7e61 100644 --- a/packages/react-dom/src/__tests__/ReactUpdates-test.js +++ b/packages/react-dom/src/__tests__/ReactUpdates-test.js @@ -21,6 +21,7 @@ let assertLog; describe('ReactUpdates', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/escapeTextForBrowser-test.js b/packages/react-dom/src/__tests__/escapeTextForBrowser-test.js index 22ae71222c370..be8dccf9f63ea 100644 --- a/packages/react-dom/src/__tests__/escapeTextForBrowser-test.js +++ b/packages/react-dom/src/__tests__/escapeTextForBrowser-test.js @@ -14,6 +14,7 @@ let ReactDOMServer; describe('escapeTextForBrowser', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMServer = require('react-dom/server'); }); diff --git a/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js b/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js index b4274d04d0767..902e3c155c3ca 100644 --- a/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js +++ b/packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js @@ -14,6 +14,7 @@ let ReactDOMServer; describe('quoteAttributeValueForBrowser', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMServer = require('react-dom/server'); }); diff --git a/packages/react-dom/src/__tests__/refs-destruction-test.js b/packages/react-dom/src/__tests__/refs-destruction-test.js index bf391a18c3fbe..97009c9e77806 100644 --- a/packages/react-dom/src/__tests__/refs-destruction-test.js +++ b/packages/react-dom/src/__tests__/refs-destruction-test.js @@ -20,6 +20,8 @@ let theInnerClassComponentRef; describe('refs-destruction', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/__tests__/refs-test.js b/packages/react-dom/src/__tests__/refs-test.js index 916835fd03d7f..e42661abd5a1f 100644 --- a/packages/react-dom/src/__tests__/refs-test.js +++ b/packages/react-dom/src/__tests__/refs-test.js @@ -22,6 +22,7 @@ describe('reactiverefs', () => { let container; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactFeatureFlags = require('shared/ReactFeatureFlags'); @@ -232,6 +233,7 @@ if (!ReactFeatureFlags.disableModulePatternComponents) { describe('ref swapping', () => { let RefHopsAround; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactFeatureFlags = require('shared/ReactFeatureFlags'); @@ -567,14 +569,6 @@ describe('creating element with string ref in constructor', () => { }); describe('strings refs across renderers', () => { - beforeEach(() => { - React = require('react'); - ReactDOMClient = require('react-dom/client'); - ReactFeatureFlags = require('shared/ReactFeatureFlags'); - ReactTestUtils = require('react-dom/test-utils'); - act = require('internal-test-utils').act; - }); - it('does not break', async () => { class Parent extends React.Component { render() { @@ -590,13 +584,11 @@ describe('strings refs across renderers', () => { class Indirection extends React.Component { componentDidUpdate() { - jest.resetModules(); // One ref is being rendered later using another renderer copy. + jest.resetModules(); const AnotherCopyOfReactDOM = require('react-dom'); const AnotherCopyOfReactDOMClient = require('react-dom/client'); const root = AnotherCopyOfReactDOMClient.createRoot(div2); - - // TODO: this should error since flushSync is called in a lifecycle. AnotherCopyOfReactDOM.flushSync(() => { root.render(this.props.child2); }); diff --git a/packages/react-dom/src/__tests__/refsLegacy-test.js b/packages/react-dom/src/__tests__/refsLegacy-test.js index 5e19289d395c7..c3af817892ffa 100644 --- a/packages/react-dom/src/__tests__/refsLegacy-test.js +++ b/packages/react-dom/src/__tests__/refsLegacy-test.js @@ -14,6 +14,7 @@ let ReactDOM = require('react-dom'); describe('root level refs with legacy APIs', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); }); diff --git a/packages/react-dom/src/events/__tests__/SyntheticFocusEvent-test.js b/packages/react-dom/src/events/__tests__/SyntheticFocusEvent-test.js index bf4fab696741e..ef889c4b60d10 100644 --- a/packages/react-dom/src/events/__tests__/SyntheticFocusEvent-test.js +++ b/packages/react-dom/src/events/__tests__/SyntheticFocusEvent-test.js @@ -14,6 +14,7 @@ describe('SyntheticFocusEvent', () => { let container; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; diff --git a/packages/react-dom/src/events/__tests__/SyntheticMouseEvent-test.js b/packages/react-dom/src/events/__tests__/SyntheticMouseEvent-test.js index 5c252a74beb5c..a20886a3e2c04 100644 --- a/packages/react-dom/src/events/__tests__/SyntheticMouseEvent-test.js +++ b/packages/react-dom/src/events/__tests__/SyntheticMouseEvent-test.js @@ -17,6 +17,7 @@ describe('SyntheticMouseEvent', () => { let container; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; diff --git a/packages/react-dom/src/events/plugins/__tests__/ChangeEventPlugin-test.js b/packages/react-dom/src/events/plugins/__tests__/ChangeEventPlugin-test.js index dd5cc0130fb17..fab10a36e16d1 100644 --- a/packages/react-dom/src/events/plugins/__tests__/ChangeEventPlugin-test.js +++ b/packages/react-dom/src/events/plugins/__tests__/ChangeEventPlugin-test.js @@ -37,6 +37,7 @@ describe('ChangeEventPlugin', () => { let container; beforeEach(() => { + jest.resetModules(); // TODO pull this into helper method, reduce repetition. // mock the browser APIs which are used in schedule: // - calling 'window.postMessage' should actually fire postmessage handlers diff --git a/packages/react-dom/src/events/plugins/__tests__/EnterLeaveEventPlugin-test.js b/packages/react-dom/src/events/plugins/__tests__/EnterLeaveEventPlugin-test.js index ee4cb594f721f..569a29a22a5b8 100644 --- a/packages/react-dom/src/events/plugins/__tests__/EnterLeaveEventPlugin-test.js +++ b/packages/react-dom/src/events/plugins/__tests__/EnterLeaveEventPlugin-test.js @@ -18,6 +18,8 @@ describe('EnterLeaveEventPlugin', () => { let container; beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-dom/src/events/plugins/__tests__/SimpleEventPlugin-test.js b/packages/react-dom/src/events/plugins/__tests__/SimpleEventPlugin-test.js index 1110c62e61977..4cd9c8f27e6f5 100644 --- a/packages/react-dom/src/events/plugins/__tests__/SimpleEventPlugin-test.js +++ b/packages/react-dom/src/events/plugins/__tests__/SimpleEventPlugin-test.js @@ -44,6 +44,7 @@ describe('SimpleEventPlugin', function () { } beforeEach(function () { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); Scheduler = require('scheduler'); @@ -256,6 +257,8 @@ describe('SimpleEventPlugin', function () { describe('interactive events, in concurrent mode', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOMClient = require('react-dom/client'); Scheduler = require('scheduler'); diff --git a/packages/react-is/src/__tests__/ReactIs-test.js b/packages/react-is/src/__tests__/ReactIs-test.js index 07d90eae157d2..5b63eebd529fd 100644 --- a/packages/react-is/src/__tests__/ReactIs-test.js +++ b/packages/react-is/src/__tests__/ReactIs-test.js @@ -16,6 +16,8 @@ let SuspenseList; describe('ReactIs', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOM = require('react-dom'); ReactIs = require('react-is'); diff --git a/packages/react-reconciler/src/__tests__/Activity-test.js b/packages/react-reconciler/src/__tests__/Activity-test.js index 780cb065c088c..fc6a8b563d197 100644 --- a/packages/react-reconciler/src/__tests__/Activity-test.js +++ b/packages/react-reconciler/src/__tests__/Activity-test.js @@ -16,6 +16,8 @@ let assertLog; describe('Activity', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ActivityStrictMode-test.js b/packages/react-reconciler/src/__tests__/ActivityStrictMode-test.js index b7a1306e28303..a8b8d286dc6aa 100644 --- a/packages/react-reconciler/src/__tests__/ActivityStrictMode-test.js +++ b/packages/react-reconciler/src/__tests__/ActivityStrictMode-test.js @@ -6,6 +6,7 @@ let log; describe('Activity StrictMode', () => { beforeEach(() => { + jest.resetModules(); log = []; React = require('react'); diff --git a/packages/react-reconciler/src/__tests__/ActivitySuspense-test.js b/packages/react-reconciler/src/__tests__/ActivitySuspense-test.js index c27b0de4cb507..a2b4de2e0ce51 100644 --- a/packages/react-reconciler/src/__tests__/ActivitySuspense-test.js +++ b/packages/react-reconciler/src/__tests__/ActivitySuspense-test.js @@ -15,6 +15,8 @@ let assertLog; describe('Activity Suspense', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactActWarnings-test.js b/packages/react-reconciler/src/__tests__/ReactActWarnings-test.js index 378e8b250caa2..61cde5648a9e6 100644 --- a/packages/react-reconciler/src/__tests__/ReactActWarnings-test.js +++ b/packages/react-reconciler/src/__tests__/ReactActWarnings-test.js @@ -24,6 +24,7 @@ let caches; // React 17. describe('act warnings', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); Scheduler = require('scheduler'); ReactNoop = require('react-noop-renderer'); diff --git a/packages/react-reconciler/src/__tests__/ReactAsyncActions-test.js b/packages/react-reconciler/src/__tests__/ReactAsyncActions-test.js index b8c5a9005d06f..0a29be2b6fec9 100644 --- a/packages/react-reconciler/src/__tests__/ReactAsyncActions-test.js +++ b/packages/react-reconciler/src/__tests__/ReactAsyncActions-test.js @@ -10,6 +10,8 @@ let textCache; describe('ReactAsyncActions', () => { beforeEach(() => { + jest.resetModules(); + global.reportError = error => { Scheduler.log('reportError: ' + error.message); }; diff --git a/packages/react-reconciler/src/__tests__/ReactCPUSuspense-test.js b/packages/react-reconciler/src/__tests__/ReactCPUSuspense-test.js index a504ed874d30f..d640f87205e45 100644 --- a/packages/react-reconciler/src/__tests__/ReactCPUSuspense-test.js +++ b/packages/react-reconciler/src/__tests__/ReactCPUSuspense-test.js @@ -15,6 +15,8 @@ let waitForPaint; describe('ReactSuspenseWithNoopRenderer', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactCache-test.js b/packages/react-reconciler/src/__tests__/ReactCache-test.js index 7caf1e7e9678f..b32479b70bbf5 100644 --- a/packages/react-reconciler/src/__tests__/ReactCache-test.js +++ b/packages/react-reconciler/src/__tests__/ReactCache-test.js @@ -17,6 +17,7 @@ let cache; describe('ReactCache', () => { beforeEach(() => { + jest.resetModules(); jest.mock('react', () => require('react/react.react-server')); React = require('react'); @@ -203,6 +204,7 @@ describe('ReactCache', () => { it('introspection of returned wrapper function is same on client and server', async () => { // When the variant flag is true, test the client version of `cache`. if (gate(flags => flags.variant)) { + jest.resetModules(); jest.mock('react', () => jest.requireActual('react')); const ClientReact = require('react'); cache = ClientReact.cache; diff --git a/packages/react-reconciler/src/__tests__/ReactCacheElement-test.js b/packages/react-reconciler/src/__tests__/ReactCacheElement-test.js index 4baae39b440eb..19d3180af650c 100644 --- a/packages/react-reconciler/src/__tests__/ReactCacheElement-test.js +++ b/packages/react-reconciler/src/__tests__/ReactCacheElement-test.js @@ -17,6 +17,8 @@ let seededCache; describe('ReactCacheElement', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Cache = React.unstable_Cache; diff --git a/packages/react-reconciler/src/__tests__/ReactClassSetStateCallback-test.js b/packages/react-reconciler/src/__tests__/ReactClassSetStateCallback-test.js index f4fa62a524ae3..e9b25f2ca74dc 100644 --- a/packages/react-reconciler/src/__tests__/ReactClassSetStateCallback-test.js +++ b/packages/react-reconciler/src/__tests__/ReactClassSetStateCallback-test.js @@ -6,6 +6,8 @@ let assertLog; describe('ReactClassSetStateCallback', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactConcurrentErrorRecovery-test.js b/packages/react-reconciler/src/__tests__/ReactConcurrentErrorRecovery-test.js index ffbf330a876c4..8c4f0d3415cec 100644 --- a/packages/react-reconciler/src/__tests__/ReactConcurrentErrorRecovery-test.js +++ b/packages/react-reconciler/src/__tests__/ReactConcurrentErrorRecovery-test.js @@ -12,6 +12,8 @@ let seededCache; describe('ReactConcurrentErrorRecovery', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js b/packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js index 37c4771778554..3247e8758e079 100644 --- a/packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js +++ b/packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js @@ -13,6 +13,8 @@ let assertLog; describe('ReactLazyContextPropagation', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactDeferredValue-test.js b/packages/react-reconciler/src/__tests__/ReactDeferredValue-test.js index fb0de990d7d97..b321f4bba0de4 100644 --- a/packages/react-reconciler/src/__tests__/ReactDeferredValue-test.js +++ b/packages/react-reconciler/src/__tests__/ReactDeferredValue-test.js @@ -23,6 +23,8 @@ let textCache; describe('ReactDeferredValue', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactEffectOrdering-test.js b/packages/react-reconciler/src/__tests__/ReactEffectOrdering-test.js index 29ef30d639257..259492f294cfc 100644 --- a/packages/react-reconciler/src/__tests__/ReactEffectOrdering-test.js +++ b/packages/react-reconciler/src/__tests__/ReactEffectOrdering-test.js @@ -22,6 +22,7 @@ let assertLog; describe('ReactEffectOrdering', () => { beforeEach(() => { + jest.resetModules(); jest.useFakeTimers(); React = require('react'); diff --git a/packages/react-reconciler/src/__tests__/ReactExpiration-test.js b/packages/react-reconciler/src/__tests__/ReactExpiration-test.js index ef560f4ffe4c2..cd09ca347885b 100644 --- a/packages/react-reconciler/src/__tests__/ReactExpiration-test.js +++ b/packages/react-reconciler/src/__tests__/ReactExpiration-test.js @@ -25,6 +25,8 @@ let unstable_waitForExpired; describe('ReactExpiration', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); @@ -403,6 +405,7 @@ describe('ReactExpiration', () => { // Tests an implementation detail where expiration times are computed using // bitwise operations. + jest.resetModules(); Scheduler = require('scheduler'); if (gate(flags => flags.forceConcurrentByDefaultForTesting)) { diff --git a/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js b/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js index 8e965cc12bdbd..e2d9ba76660f9 100644 --- a/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js +++ b/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js @@ -12,6 +12,8 @@ let waitForPaint; describe('ReactFlushSync', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactFlushSyncNoAggregateError-test.js b/packages/react-reconciler/src/__tests__/ReactFlushSyncNoAggregateError-test.js index 9f87497b3fd67..8c1bc7475be36 100644 --- a/packages/react-reconciler/src/__tests__/ReactFlushSyncNoAggregateError-test.js +++ b/packages/react-reconciler/src/__tests__/ReactFlushSyncNoAggregateError-test.js @@ -11,6 +11,8 @@ let flushFakeMicrotasks; describe('ReactFlushSync (AggregateError not available)', () => { beforeEach(() => { + jest.resetModules(); + global.AggregateError = undefined; // When AggregateError is not available, the errors are rethrown in a diff --git a/packages/react-reconciler/src/__tests__/ReactFragment-test.js b/packages/react-reconciler/src/__tests__/ReactFragment-test.js index 29ad974f4ad99..3db7702f4cfef 100644 --- a/packages/react-reconciler/src/__tests__/ReactFragment-test.js +++ b/packages/react-reconciler/src/__tests__/ReactFragment-test.js @@ -15,6 +15,8 @@ let waitForAll; describe('ReactFragment', () => { beforeEach(function () { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); diff --git a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js index 204c1a2089e40..89d150ed09888 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js +++ b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js @@ -43,6 +43,7 @@ let assertLog; describe('ReactHooksWithNoopRenderer', () => { beforeEach(() => { + jest.resetModules(); jest.useFakeTimers(); React = require('react'); diff --git a/packages/react-reconciler/src/__tests__/ReactIncremental-test.js b/packages/react-reconciler/src/__tests__/ReactIncremental-test.js index d3ddfa900524c..13f904bf9d014 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncremental-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncremental-test.js @@ -21,6 +21,7 @@ let assertLog; describe('ReactIncremental', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); @@ -2718,6 +2719,7 @@ describe('ReactIncremental', () => { // First, verify that this code path normally receives Fibers as keys, // and that they're not extensible. + jest.resetModules(); let receivedNonExtensibleObjects; // eslint-disable-next-line no-extend-native Map.prototype.set = function (key) { diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalErrorLogging-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalErrorLogging-test.js index d366ccc0970fa..e56d0f30d7bce 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalErrorLogging-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalErrorLogging-test.js @@ -18,6 +18,7 @@ let waitForThrow; describe('ReactIncrementalErrorLogging', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalErrorReplay-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalErrorReplay-test.js index eb8ef9095a190..ed4317d95706e 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalErrorReplay-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalErrorReplay-test.js @@ -17,6 +17,7 @@ let waitForThrow; describe('ReactIncrementalErrorReplay', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js index 65dba58d4fe7e..cffd690e64715 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js @@ -18,6 +18,8 @@ let waitForAll; describe('ReactIncrementalReflection', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js index 445ff979839e3..8c00ec741206e 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js @@ -21,6 +21,8 @@ let waitForPaint; describe('ReactIncrementalScheduling', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js index 9dac866df1ad7..b47897e54d92e 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js @@ -19,6 +19,8 @@ let waitForPaint; describe('ReactIncrementalSideEffects', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js index d75193883e3db..f3d5cbc675c52 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js @@ -21,6 +21,8 @@ let assertLog; describe('ReactIncrementalUpdates', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalUpdatesMinimalism-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalUpdatesMinimalism-test.js index 79110760d315e..5f1959de160af 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalUpdatesMinimalism-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalUpdatesMinimalism-test.js @@ -16,6 +16,7 @@ let act; describe('ReactIncrementalUpdatesMinimalism', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); diff --git a/packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js b/packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js index 47ea906808323..7e676861b5d31 100644 --- a/packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js +++ b/packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js @@ -11,6 +11,8 @@ let waitForPaint; describe('ReactInterleavedUpdates', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactMemo-test.js b/packages/react-reconciler/src/__tests__/ReactMemo-test.js index 2f51e8fc81b89..a7b47621d53e2 100644 --- a/packages/react-reconciler/src/__tests__/ReactMemo-test.js +++ b/packages/react-reconciler/src/__tests__/ReactMemo-test.js @@ -23,6 +23,8 @@ let assertLog; describe('memo', () => { beforeEach(() => { + jest.resetModules(); + PropTypes = require('prop-types'); React = require('react'); ReactNoop = require('react-noop-renderer'); diff --git a/packages/react-reconciler/src/__tests__/ReactNewContext-test.js b/packages/react-reconciler/src/__tests__/ReactNewContext-test.js index a6cabd6c641f7..e51ca08f2b8e8 100644 --- a/packages/react-reconciler/src/__tests__/ReactNewContext-test.js +++ b/packages/react-reconciler/src/__tests__/ReactNewContext-test.js @@ -20,6 +20,8 @@ let waitForThrow; describe('ReactNewContext', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); useContext = React.useContext; ReactNoop = require('react-noop-renderer'); diff --git a/packages/react-reconciler/src/__tests__/ReactPersistent-test.js b/packages/react-reconciler/src/__tests__/ReactPersistent-test.js index 06560430c7792..7900ccdadd451 100644 --- a/packages/react-reconciler/src/__tests__/ReactPersistent-test.js +++ b/packages/react-reconciler/src/__tests__/ReactPersistent-test.js @@ -16,6 +16,8 @@ let waitForAll; describe('ReactPersistent', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoopPersistent = require('react-noop-renderer/persistent'); const InternalTestUtils = require('internal-test-utils'); diff --git a/packages/react-reconciler/src/__tests__/ReactPersistentUpdatesMinimalism-test.js b/packages/react-reconciler/src/__tests__/ReactPersistentUpdatesMinimalism-test.js index 173b3064a5cba..359c80c247f02 100644 --- a/packages/react-reconciler/src/__tests__/ReactPersistentUpdatesMinimalism-test.js +++ b/packages/react-reconciler/src/__tests__/ReactPersistentUpdatesMinimalism-test.js @@ -16,6 +16,7 @@ let act; describe('ReactPersistentUpdatesMinimalism', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactNoopPersistent = require('react-noop-renderer/persistent'); act = require('internal-test-utils').act; diff --git a/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js b/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js index 7658fbadbae30..a29280b36c569 100644 --- a/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js @@ -25,6 +25,8 @@ let waitFor; describe('ReactSchedulerIntegration', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); @@ -193,6 +195,8 @@ describe( let logDuringShouldYield = false; beforeEach(() => { + jest.resetModules(); + jest.mock('scheduler', () => { const actual = jest.requireActual('scheduler/unstable_mock'); return { @@ -322,6 +326,8 @@ describe('`act` bypasses Scheduler methods completely,', () => { let infiniteLoopGuard; beforeEach(() => { + jest.resetModules(); + infiniteLoopGuard = 0; jest.mock('scheduler', () => { diff --git a/packages/react-reconciler/src/__tests__/ReactSubtreeFlagsWarning-test.js b/packages/react-reconciler/src/__tests__/ReactSubtreeFlagsWarning-test.js index 4ae9f7f61ca1c..49bde67837cdf 100644 --- a/packages/react-reconciler/src/__tests__/ReactSubtreeFlagsWarning-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSubtreeFlagsWarning-test.js @@ -12,6 +12,8 @@ let assertLog; describe('ReactSuspenseWithNoopRenderer', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseCallback-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseCallback-test.js index 7e354f858a5ed..8706d9e248ce6 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseCallback-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseCallback-test.js @@ -16,6 +16,8 @@ let act; describe('ReactSuspense', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemantics-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemantics-test.js index 8c8edb39c0f97..5200635b6fca4 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemantics-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemantics-test.js @@ -24,6 +24,8 @@ let assertLog; describe('ReactSuspenseEffectsSemantics', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemanticsDOM-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemanticsDOM-test.js index 87eb80c3b2342..2a6b02acfe4f3 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemanticsDOM-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemanticsDOM-test.js @@ -21,6 +21,8 @@ let fakeModuleCache; describe('ReactSuspenseEffectsSemanticsDOM', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseFallback-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseFallback-test.js index 07968fcae55c4..8dcf5fda13695 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseFallback-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseFallback-test.js @@ -17,6 +17,8 @@ let waitForAll; describe('ReactSuspenseFallback', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js index b5e753e4aca2a..432546c683f5b 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js @@ -11,6 +11,8 @@ let waitFor; describe('ReactSuspenseList', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js index c1b8e34368378..77aae6ee53d9b 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js @@ -17,6 +17,8 @@ let seededCache; describe('ReactSuspenseWithNoopRenderer', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); Fragment = React.Fragment; ReactNoop = require('react-noop-renderer'); diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js index e64a2873b8541..52fd9ef3f27d8 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js @@ -14,6 +14,8 @@ let waitForPaint; describe('ReactSuspenseyCommitPhase', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactTopLevelFragment-test.js b/packages/react-reconciler/src/__tests__/ReactTopLevelFragment-test.js index 20b307886fdd3..38b0d0a52633a 100644 --- a/packages/react-reconciler/src/__tests__/ReactTopLevelFragment-test.js +++ b/packages/react-reconciler/src/__tests__/ReactTopLevelFragment-test.js @@ -18,6 +18,7 @@ let waitForAll; // probably move to one of the other test files once it is official. describe('ReactTopLevelFragment', function () { beforeEach(function () { + jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); diff --git a/packages/react-reconciler/src/__tests__/ReactTopLevelText-test.js b/packages/react-reconciler/src/__tests__/ReactTopLevelText-test.js index 7fe6c4dfb84b2..30a3fa093b4ab 100644 --- a/packages/react-reconciler/src/__tests__/ReactTopLevelText-test.js +++ b/packages/react-reconciler/src/__tests__/ReactTopLevelText-test.js @@ -18,6 +18,7 @@ let waitForAll; // probably move to one of the other test files once it is official. describe('ReactTopLevelText', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); diff --git a/packages/react-reconciler/src/__tests__/ReactTransition-test.js b/packages/react-reconciler/src/__tests__/ReactTransition-test.js index 67fc502d101ce..e5c69665f31c2 100644 --- a/packages/react-reconciler/src/__tests__/ReactTransition-test.js +++ b/packages/react-reconciler/src/__tests__/ReactTransition-test.js @@ -30,6 +30,7 @@ let seededCache; describe('ReactTransition', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js b/packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js index 1a2b7c859e779..72397a8446a52 100644 --- a/packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js +++ b/packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js @@ -37,6 +37,8 @@ describe('ReactInteractionTracing', () => { .join(', '); } beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactUpdatePriority-test.js b/packages/react-reconciler/src/__tests__/ReactUpdatePriority-test.js index 6128180319b5f..c5de798366334 100644 --- a/packages/react-reconciler/src/__tests__/ReactUpdatePriority-test.js +++ b/packages/react-reconciler/src/__tests__/ReactUpdatePriority-test.js @@ -12,6 +12,8 @@ let assertLog; describe('ReactUpdatePriority', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/ReactUse-test.js b/packages/react-reconciler/src/__tests__/ReactUse-test.js index d66b27c81d477..12e93620b5ded 100644 --- a/packages/react-reconciler/src/__tests__/ReactUse-test.js +++ b/packages/react-reconciler/src/__tests__/ReactUse-test.js @@ -20,6 +20,8 @@ let waitForMicrotasks; describe('ReactUse', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js b/packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js index fd7d6c4ef31c6..62ff0e19e6230 100644 --- a/packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js +++ b/packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js @@ -17,6 +17,7 @@ let assertLog; describe('StrictEffectsMode', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactTestRenderer = require('react-test-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-reconciler/src/__tests__/useEffectEvent-test.js b/packages/react-reconciler/src/__tests__/useEffectEvent-test.js index f140351a02698..38cdae73f0124 100644 --- a/packages/react-reconciler/src/__tests__/useEffectEvent-test.js +++ b/packages/react-reconciler/src/__tests__/useEffectEvent-test.js @@ -12,6 +12,8 @@ 'use strict'; +import {useInsertionEffect} from 'react'; + describe('useEffectEvent', () => { let React; let ReactNoop; @@ -23,7 +25,6 @@ describe('useEffectEvent', () => { let useEffectEvent; let useEffect; let useLayoutEffect; - let useInsertionEffect; let useMemo; let waitForAll; let assertLog; @@ -42,7 +43,6 @@ describe('useEffectEvent', () => { useEffect = React.useEffect; useLayoutEffect = React.useLayoutEffect; useMemo = React.useMemo; - useInsertionEffect = React.useInsertionEffect; const InternalTestUtils = require('internal-test-utils'); waitForAll = InternalTestUtils.waitForAll; diff --git a/packages/react-reconciler/src/__tests__/useMemoCache-test.js b/packages/react-reconciler/src/__tests__/useMemoCache-test.js index 1eea6bd3394cc..94571df0f9d83 100644 --- a/packages/react-reconciler/src/__tests__/useMemoCache-test.js +++ b/packages/react-reconciler/src/__tests__/useMemoCache-test.js @@ -18,6 +18,8 @@ let ErrorBoundary; describe('useMemoCache()', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); act = require('internal-test-utils').act; diff --git a/packages/react-reconciler/src/__tests__/useSyncExternalStore-test.js b/packages/react-reconciler/src/__tests__/useSyncExternalStore-test.js index 4222bff18368b..67cefa180aa74 100644 --- a/packages/react-reconciler/src/__tests__/useSyncExternalStore-test.js +++ b/packages/react-reconciler/src/__tests__/useSyncExternalStore-test.js @@ -32,6 +32,8 @@ let assertLog; // React DOM versions (16, 17, etc) instead of React Noop. describe('useSyncExternalStore', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-refresh/src/__tests__/ReactFresh-test.js b/packages/react-refresh/src/__tests__/ReactFresh-test.js index 50ea4cb6b7e7d..38b74563c30a7 100644 --- a/packages/react-refresh/src/__tests__/ReactFresh-test.js +++ b/packages/react-refresh/src/__tests__/ReactFresh-test.js @@ -27,6 +27,7 @@ describe('ReactFresh', () => { beforeEach(() => { if (__DEV__) { + jest.resetModules(); React = require('react'); ReactFreshRuntime = require('react-refresh/runtime'); ReactFreshRuntime.injectIntoGlobalHook(global); diff --git a/packages/react-refresh/src/__tests__/ReactFreshIntegration-test.js b/packages/react-refresh/src/__tests__/ReactFreshIntegration-test.js index c5eec3f2c4187..ed8c56072a217 100644 --- a/packages/react-refresh/src/__tests__/ReactFreshIntegration-test.js +++ b/packages/react-refresh/src/__tests__/ReactFreshIntegration-test.js @@ -29,6 +29,7 @@ describe('ReactFreshIntegration', () => { beforeEach(() => { if (__DEV__) { + jest.resetModules(); React = require('react'); ReactFreshRuntime = require('react-refresh/runtime'); ReactFreshRuntime.injectIntoGlobalHook(global); diff --git a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMBrowser-test.js b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMBrowser-test.js index 0a214a259fc5f..d797946a3fd3d 100644 --- a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMBrowser-test.js +++ b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMBrowser-test.js @@ -21,6 +21,8 @@ let ReactServerDOMClient; describe('ReactFlightDOMBrowser', () => { beforeEach(() => { + jest.resetModules(); + // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-turbopack/server', () => diff --git a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMEdge-test.js b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMEdge-test.js index 3b736f7f8c3c6..67d25c967f472 100644 --- a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMEdge-test.js +++ b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMEdge-test.js @@ -30,6 +30,8 @@ let use; describe('ReactFlightDOMEdge', () => { beforeEach(() => { + jest.resetModules(); + // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-turbopack/server', () => diff --git a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMForm-test.js b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMForm-test.js index 0ec3bc184275f..3f63222d0ae2d 100644 --- a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMForm-test.js +++ b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMForm-test.js @@ -31,6 +31,7 @@ let ReactServerDOMClient; describe('ReactFlightDOMForm', () => { beforeEach(() => { + jest.resetModules(); // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-turbopack/server', () => diff --git a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMNode-test.js b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMNode-test.js index 448d5f3e01626..e06ee0a32f950 100644 --- a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMNode-test.js +++ b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMNode-test.js @@ -26,6 +26,8 @@ let use; describe('ReactFlightDOMNode', () => { beforeEach(() => { + jest.resetModules(); + // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-turbopack/server', () => diff --git a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReply-test.js b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReply-test.js index d83237681f207..e47352cfe981d 100644 --- a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReply-test.js +++ b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReply-test.js @@ -22,6 +22,7 @@ let ReactServerDOMClient; describe('ReactFlightDOMReply', () => { beforeEach(() => { + jest.resetModules(); // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-turbopack/server', () => diff --git a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReplyEdge-test.js b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReplyEdge-test.js index 99fad128bab53..0cd8605c7e8d6 100644 --- a/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReplyEdge-test.js +++ b/packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReplyEdge-test.js @@ -22,6 +22,7 @@ let ReactServerDOMClient; describe('ReactFlightDOMReply', () => { beforeEach(() => { + jest.resetModules(); // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-turbopack/server', () => diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js index b5b66df1b91e1..91ba06dd329b9 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOM-test.js @@ -42,6 +42,8 @@ describe('ReactFlightDOM', () => { // For this first reset we are going to load the dom-node version of react-server-dom-webpack/server // This can be thought of as essentially being the React Server Components scope with react-server // condition + jest.resetModules(); + JSDOM = require('jsdom').JSDOM; // Simulate the condition resolution diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js index 59e34256f0547..2427317ce2c32 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js @@ -33,6 +33,8 @@ let ReactServerDOM; describe('ReactFlightDOMBrowser', () => { beforeEach(() => { + jest.resetModules(); + // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-webpack/server', () => diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js index eb2298197dfbb..4b64875c3f89f 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js @@ -31,6 +31,8 @@ let use; describe('ReactFlightDOMEdge', () => { beforeEach(() => { + jest.resetModules(); + // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-webpack/server', () => diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js index 604ac14a095ee..dcab688b10c83 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js @@ -36,6 +36,7 @@ let act; describe('ReactFlightDOMForm', () => { beforeEach(() => { + jest.resetModules(); // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-webpack/server', () => diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMNode-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMNode-test.js index 82b35657f26dd..87fc83360018e 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMNode-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMNode-test.js @@ -26,6 +26,8 @@ let use; describe('ReactFlightDOMNode', () => { beforeEach(() => { + jest.resetModules(); + // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-webpack/server', () => diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReply-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReply-test.js index 6df1655e5121a..1162d1d0fe738 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReply-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReply-test.js @@ -22,6 +22,7 @@ let ReactServerDOMClient; describe('ReactFlightDOMReply', () => { beforeEach(() => { + jest.resetModules(); // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-webpack/server', () => diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReplyEdge-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReplyEdge-test.js index 9cdc60969a1ba..8e45472956294 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReplyEdge-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMReplyEdge-test.js @@ -22,6 +22,7 @@ let ReactServerDOMClient; describe('ReactFlightDOMReplyEdge', () => { beforeEach(() => { + jest.resetModules(); // Simulate the condition resolution jest.mock('react', () => require('react/react.react-server')); jest.mock('react-server-dom-webpack/server', () => diff --git a/packages/react-server/src/__tests__/ReactServer-test.js b/packages/react-server/src/__tests__/ReactServer-test.js index 0293d3593364f..d827e82de0cac 100644 --- a/packages/react-server/src/__tests__/ReactServer-test.js +++ b/packages/react-server/src/__tests__/ReactServer-test.js @@ -15,6 +15,8 @@ let ReactNoopServer; describe('ReactServer', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactNoopServer = require('react-noop-renderer/server'); }); diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js index 6de4d6be4a425..0118fa53f3ad3 100644 --- a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js +++ b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js @@ -17,6 +17,7 @@ let waitForAll; describe('ReactTestRenderer', () => { beforeEach(() => { + jest.resetModules(); ReactDOM = require('react-dom'); // Isolate test renderer. diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRendererAct-test.js b/packages/react-test-renderer/src/__tests__/ReactTestRendererAct-test.js index aa89d2fc0b775..2306a895b785c 100644 --- a/packages/react-test-renderer/src/__tests__/ReactTestRendererAct-test.js +++ b/packages/react-test-renderer/src/__tests__/ReactTestRendererAct-test.js @@ -8,6 +8,7 @@ let assertLog; describe('ReactTestRenderer.act()', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactTestRenderer = require('react-test-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js b/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js index 7c319a2f50aaa..51c7e0a950ddc 100644 --- a/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js +++ b/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js @@ -18,6 +18,8 @@ let waitFor; describe('ReactTestRendererAsync', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactTestRenderer = require('react-test-renderer'); Scheduler = require('scheduler'); diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRendererTraversal-test.js b/packages/react-test-renderer/src/__tests__/ReactTestRendererTraversal-test.js index cffc417ab775e..d61f0a7c9075a 100644 --- a/packages/react-test-renderer/src/__tests__/ReactTestRendererTraversal-test.js +++ b/packages/react-test-renderer/src/__tests__/ReactTestRendererTraversal-test.js @@ -19,6 +19,7 @@ const View = props => ; describe('ReactTestRendererTraversal', () => { beforeEach(() => { + jest.resetModules(); ReactTestRenderer = require('react-test-renderer'); Context = React.createContext(null); }); diff --git a/packages/react/src/__tests__/ReactChildren-test.js b/packages/react/src/__tests__/ReactChildren-test.js index 4d6a89be8bcce..016e4089d8d3a 100644 --- a/packages/react/src/__tests__/ReactChildren-test.js +++ b/packages/react/src/__tests__/ReactChildren-test.js @@ -15,6 +15,7 @@ describe('ReactChildren', () => { let act; beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; diff --git a/packages/react/src/__tests__/ReactContextValidator-test.js b/packages/react/src/__tests__/ReactContextValidator-test.js index 3f0fc6ad419ca..c2c97e0c87a9d 100644 --- a/packages/react/src/__tests__/ReactContextValidator-test.js +++ b/packages/react/src/__tests__/ReactContextValidator-test.js @@ -24,6 +24,8 @@ let act; describe('ReactContextValidator', () => { beforeEach(() => { + jest.resetModules(); + PropTypes = require('prop-types'); React = require('react'); ReactDOMClient = require('react-dom/client'); diff --git a/packages/react/src/__tests__/ReactCreateElement-test.js b/packages/react/src/__tests__/ReactCreateElement-test.js index 7c6a623be1700..6d1a16e3bb145 100644 --- a/packages/react/src/__tests__/ReactCreateElement-test.js +++ b/packages/react/src/__tests__/ReactCreateElement-test.js @@ -20,6 +20,8 @@ describe('ReactCreateElement', () => { let ComponentClass; beforeEach(() => { + jest.resetModules(); + act = require('internal-test-utils').act; React = require('react'); diff --git a/packages/react/src/__tests__/ReactCreateRef-test.js b/packages/react/src/__tests__/ReactCreateRef-test.js index 9e45930ce8454..5c560152b0b26 100644 --- a/packages/react/src/__tests__/ReactCreateRef-test.js +++ b/packages/react/src/__tests__/ReactCreateRef-test.js @@ -14,6 +14,8 @@ let ReactTestRenderer; describe('ReactCreateRef', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactTestRenderer = require('react-test-renderer'); }); diff --git a/packages/react/src/__tests__/ReactFetch-test.js b/packages/react/src/__tests__/ReactFetch-test.js index f89cce08fc138..78fd5d622cd73 100644 --- a/packages/react/src/__tests__/ReactFetch-test.js +++ b/packages/react/src/__tests__/ReactFetch-test.js @@ -40,6 +40,7 @@ let cache; describe('ReactFetch', () => { beforeEach(() => { + jest.resetModules(); fetchCount = 0; global.fetch = fetchMock; diff --git a/packages/react/src/__tests__/ReactFetchEdge-test.js b/packages/react/src/__tests__/ReactFetchEdge-test.js index 67afab7ca3e84..741306a9a2e4a 100644 --- a/packages/react/src/__tests__/ReactFetchEdge-test.js +++ b/packages/react/src/__tests__/ReactFetchEdge-test.js @@ -44,6 +44,7 @@ let use; describe('ReactFetch', () => { beforeEach(() => { + jest.resetModules(); fetchCount = 0; global.fetch = fetchMock; diff --git a/packages/react/src/__tests__/ReactJSXElementValidator-test.js b/packages/react/src/__tests__/ReactJSXElementValidator-test.js index 3b2a9fd83bd1d..b7cdff0ce0aa1 100644 --- a/packages/react/src/__tests__/ReactJSXElementValidator-test.js +++ b/packages/react/src/__tests__/ReactJSXElementValidator-test.js @@ -23,6 +23,8 @@ describe('ReactJSXElementValidator', () => { let RequiredPropComponent; beforeEach(() => { + jest.resetModules(); + PropTypes = require('prop-types'); React = require('react'); ReactDOM = require('react-dom'); diff --git a/packages/react/src/__tests__/ReactJSXRuntime-test.js b/packages/react/src/__tests__/ReactJSXRuntime-test.js index aee64650d1c50..713430fa5ead9 100644 --- a/packages/react/src/__tests__/ReactJSXRuntime-test.js +++ b/packages/react/src/__tests__/ReactJSXRuntime-test.js @@ -22,6 +22,8 @@ let act; // transform that we use in our tests configuration. describe('ReactJSXRuntime', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); JSXRuntime = require('react/jsx-runtime'); JSXDEVRuntime = require('react/jsx-dev-runtime'); diff --git a/packages/react/src/__tests__/ReactJSXTransformIntegration-test.js b/packages/react/src/__tests__/ReactJSXTransformIntegration-test.js index ede9d60261e3f..6f764db3b11ce 100644 --- a/packages/react/src/__tests__/ReactJSXTransformIntegration-test.js +++ b/packages/react/src/__tests__/ReactJSXTransformIntegration-test.js @@ -26,6 +26,8 @@ describe('ReactJSXTransformIntegration', () => { let Component; beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOMClient = require('react-dom/client'); ReactTestUtils = require('react-dom/test-utils'); diff --git a/packages/react/src/__tests__/ReactStartTransition-test.js b/packages/react/src/__tests__/ReactStartTransition-test.js index b60cb7b6ca1e1..c98372a7c74b7 100644 --- a/packages/react/src/__tests__/ReactStartTransition-test.js +++ b/packages/react/src/__tests__/ReactStartTransition-test.js @@ -19,6 +19,7 @@ const SUSPICIOUS_NUMBER_OF_FIBERS_UPDATED = 10; describe('ReactStartTransition', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactTestRenderer = require('react-test-renderer'); act = require('internal-test-utils').act; diff --git a/packages/react/src/__tests__/ReactStrictMode-test.js b/packages/react/src/__tests__/ReactStrictMode-test.js index 4ccc9a2687175..28dd94ad06ca2 100644 --- a/packages/react/src/__tests__/ReactStrictMode-test.js +++ b/packages/react/src/__tests__/ReactStrictMode-test.js @@ -23,6 +23,7 @@ const ReactFeatureFlags = require('shared/ReactFeatureFlags'); describe('ReactStrictMode', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); @@ -568,6 +569,8 @@ describe('ReactStrictMode', () => { describe('Concurrent Mode', () => { beforeEach(() => { + jest.resetModules(); + React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; @@ -830,6 +833,7 @@ Please update the following components: Parent`, describe('symbol checks', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; @@ -957,6 +961,7 @@ describe('symbol checks', () => { describe('string refs', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); @@ -1042,6 +1047,7 @@ describe('string refs', () => { describe('context legacy', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; @@ -1132,6 +1138,7 @@ describe('context legacy', () => { describe('console logs logging', () => { beforeEach(() => { + jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; diff --git a/packages/react/src/__tests__/createReactClassIntegration-test.js b/packages/react/src/__tests__/createReactClassIntegration-test.js index 5c1babb401f7f..dfba4146f443a 100644 --- a/packages/react/src/__tests__/createReactClassIntegration-test.js +++ b/packages/react/src/__tests__/createReactClassIntegration-test.js @@ -18,6 +18,7 @@ let createReactClass; describe('create-react-class-integration', () => { beforeEach(() => { + jest.resetModules(); ({act} = require('internal-test-utils')); PropTypes = require('prop-types'); React = require('react'); diff --git a/packages/react/src/__tests__/forwardRef-test.js b/packages/react/src/__tests__/forwardRef-test.js index ed361d9015a1d..0cfa0031266eb 100644 --- a/packages/react/src/__tests__/forwardRef-test.js +++ b/packages/react/src/__tests__/forwardRef-test.js @@ -16,6 +16,7 @@ describe('forwardRef', () => { let waitForAll; beforeEach(() => { + jest.resetModules(); PropTypes = require('prop-types'); React = require('react'); ReactNoop = require('react-noop-renderer'); diff --git a/packages/scheduler/src/__tests__/Scheduler-test.js b/packages/scheduler/src/__tests__/Scheduler-test.js index 7972876894623..14ef25f3ad4f5 100644 --- a/packages/scheduler/src/__tests__/Scheduler-test.js +++ b/packages/scheduler/src/__tests__/Scheduler-test.js @@ -33,6 +33,7 @@ let NormalPriority; // assumes as little as possible about the order and timing of events. describe('SchedulerBrowser', () => { beforeEach(() => { + jest.resetModules(); runtime = installMockBrowserRuntime(); jest.unmock('scheduler'); diff --git a/packages/scheduler/src/__tests__/SchedulerMock-test.js b/packages/scheduler/src/__tests__/SchedulerMock-test.js index e93af4b29ea33..d71957ef3ebae 100644 --- a/packages/scheduler/src/__tests__/SchedulerMock-test.js +++ b/packages/scheduler/src/__tests__/SchedulerMock-test.js @@ -28,6 +28,7 @@ let waitForPaint; describe('Scheduler', () => { beforeEach(() => { + jest.resetModules(); jest.mock('scheduler', () => require('scheduler/unstable_mock')); Scheduler = require('scheduler'); diff --git a/packages/scheduler/src/__tests__/SchedulerPostTask-test.js b/packages/scheduler/src/__tests__/SchedulerPostTask-test.js index 5b40873406b31..c572ec595bb10 100644 --- a/packages/scheduler/src/__tests__/SchedulerPostTask-test.js +++ b/packages/scheduler/src/__tests__/SchedulerPostTask-test.js @@ -30,6 +30,7 @@ let shouldYield; // and timing of events. describe('SchedulerPostTask', () => { beforeEach(() => { + jest.resetModules(); jest.mock('scheduler', () => jest.requireActual('scheduler/unstable_post_task'), ); diff --git a/packages/scheduler/src/__tests__/SchedulerProfiling-test.js b/packages/scheduler/src/__tests__/SchedulerProfiling-test.js index cf44e6ae244c9..eef602d90ac3d 100644 --- a/packages/scheduler/src/__tests__/SchedulerProfiling-test.js +++ b/packages/scheduler/src/__tests__/SchedulerProfiling-test.js @@ -57,6 +57,7 @@ describe('Scheduler', () => { } beforeEach(() => { + jest.resetModules(); jest.mock('scheduler', () => require('scheduler/unstable_mock')); Scheduler = require('scheduler'); diff --git a/packages/scheduler/src/__tests__/SchedulerSetImmediate-test.js b/packages/scheduler/src/__tests__/SchedulerSetImmediate-test.js index fb41dad71e1f5..52b71b569f415 100644 --- a/packages/scheduler/src/__tests__/SchedulerSetImmediate-test.js +++ b/packages/scheduler/src/__tests__/SchedulerSetImmediate-test.js @@ -32,6 +32,7 @@ let UserBlockingPriority; // assumes as little as possible about the order and timing of events. describe('SchedulerDOMSetImmediate', () => { beforeEach(() => { + jest.resetModules(); runtime = installMockBrowserRuntime(); jest.unmock('scheduler'); diff --git a/packages/scheduler/src/__tests__/SchedulerSetTimeout-test.js b/packages/scheduler/src/__tests__/SchedulerSetTimeout-test.js index 6fb55ed19bc3f..986d329632c27 100644 --- a/packages/scheduler/src/__tests__/SchedulerSetTimeout-test.js +++ b/packages/scheduler/src/__tests__/SchedulerSetTimeout-test.js @@ -20,6 +20,7 @@ describe('SchedulerNoDOM', () => { // Scheduler falls back to a naive implementation using setTimeout. // This is only meant to be used for testing purposes, like with jest's fake timer API. beforeEach(() => { + jest.resetModules(); jest.useFakeTimers(); delete global.setImmediate; delete global.MessageChannel; @@ -99,6 +100,7 @@ describe('SchedulerNoDOM', () => { // See: https://github.com/facebook/react/pull/13088 describe('does not crash non-node SSR environments', () => { it('if setTimeout is undefined', () => { + jest.resetModules(); const originalSetTimeout = global.setTimeout; try { delete global.setTimeout; @@ -112,6 +114,7 @@ describe('does not crash non-node SSR environments', () => { }); it('if clearTimeout is undefined', () => { + jest.resetModules(); const originalClearTimeout = global.clearTimeout; try { delete global.clearTimeout; diff --git a/packages/shared/__tests__/ReactDOMFrameScheduling-test.js b/packages/shared/__tests__/ReactDOMFrameScheduling-test.js index a06e7189557e3..9295dc1010864 100644 --- a/packages/shared/__tests__/ReactDOMFrameScheduling-test.js +++ b/packages/shared/__tests__/ReactDOMFrameScheduling-test.js @@ -11,6 +11,8 @@ describe('ReactDOMFrameScheduling', () => { beforeEach(() => { + jest.resetModules(); + jest.unmock('scheduler'); }); diff --git a/packages/use-subscription/src/__tests__/useSubscription-test.js b/packages/use-subscription/src/__tests__/useSubscription-test.js index 47f59d1e25c14..9c971bd14bbb3 100644 --- a/packages/use-subscription/src/__tests__/useSubscription-test.js +++ b/packages/use-subscription/src/__tests__/useSubscription-test.js @@ -22,6 +22,7 @@ let waitFor; describe('useSubscription', () => { beforeEach(() => { + jest.resetModules(); jest.mock('scheduler', () => require('scheduler/unstable_mock')); useSubscription = require('use-subscription').useSubscription; diff --git a/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreNative-test.js b/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreNative-test.js index e3bd6c4ac0ca7..fef2d1e76f581 100644 --- a/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreNative-test.js +++ b/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreNative-test.js @@ -23,6 +23,8 @@ let assertLog; // (Node) environment describe('useSyncExternalStore (userspace shim, server rendering)', () => { beforeEach(() => { + jest.resetModules(); + // Remove useSyncExternalStore from the React imports so that we use the // shim instead. Also removing startTransition, since we use that to detect // outdated 18 alphas that don't yet include useSyncExternalStore. diff --git a/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js b/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js index 29559bb5079d4..2fe71bf73c528 100644 --- a/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js +++ b/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js @@ -26,6 +26,8 @@ let assertLog; // of useSyncExternalStore. describe('Shared useSyncExternalStore behavior (shim and built-in)', () => { beforeEach(() => { + jest.resetModules(); + if (gate(flags => flags.enableUseSyncExternalStoreShim)) { // Test the shim against React 17. jest.mock('react', () => { diff --git a/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShimServer-test.js b/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShimServer-test.js index cf7ed2148fe04..6eacb9a99c606 100644 --- a/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShimServer-test.js +++ b/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShimServer-test.js @@ -22,6 +22,8 @@ let assertLog; // (Node) environment describe('useSyncExternalStore (userspace shim, server rendering)', () => { beforeEach(() => { + jest.resetModules(); + // Remove useSyncExternalStore from the React imports so that we use the // shim instead. Also removing startTransition, since we use that to detect // outdated 18 alphas that don't yet include useSyncExternalStore. diff --git a/scripts/jest/config.base.js b/scripts/jest/config.base.js index 26c68bfc26b42..a887e66b7dd3c 100644 --- a/scripts/jest/config.base.js +++ b/scripts/jest/config.base.js @@ -6,7 +6,6 @@ module.exports = { '/scripts/rollup/shims/', '/scripts/bench/', ], - resetModules: true, transform: { '.*': require.resolve('./preprocessor.js'), },