diff --git a/packages/react-devtools-shared/src/__tests__/FastRefreshDevToolsIntegration-test.js b/packages/react-devtools-shared/src/__tests__/FastRefreshDevToolsIntegration-test.js
index f95d1a2d5fda7..2ef5ae8d02393 100644
--- a/packages/react-devtools-shared/src/__tests__/FastRefreshDevToolsIntegration-test.js
+++ b/packages/react-devtools-shared/src/__tests__/FastRefreshDevToolsIntegration-test.js
@@ -7,25 +7,20 @@
* @flow
*/
+import {getVersionedRenderImplementation} from './utils';
+
describe('Fast Refresh', () => {
let React;
let ReactFreshRuntime;
let act;
let babel;
- let container;
let exportsObj;
let freshPlugin;
- let legacyRender;
let store;
let withErrorsOrWarningsIgnored;
- afterEach(() => {
- jest.resetModules();
- });
-
beforeEach(() => {
exportsObj = undefined;
- container = document.createElement('div');
babel = require('@babel/core');
freshPlugin = require('react-refresh/babel');
@@ -39,10 +34,12 @@ describe('Fast Refresh', () => {
const utils = require('./utils');
act = utils.act;
- legacyRender = utils.legacyRender;
withErrorsOrWarningsIgnored = utils.withErrorsOrWarningsIgnored;
});
+ const {render: renderImplementation, getContainer} =
+ getVersionedRenderImplementation();
+
function execute(source) {
const compiled = babel.transform(source, {
babelrc: false,
@@ -73,7 +70,7 @@ describe('Fast Refresh', () => {
function render(source) {
const Component = execute(source);
act(() => {
- legacyRender(, container);
+ renderImplementation();
});
// Module initialization shouldn't be counted as a hot update.
expect(ReactFreshRuntime.performReactRefresh()).toBe(null);
@@ -98,7 +95,7 @@ describe('Fast Refresh', () => {
// Here, we'll just force a re-render using the newer type to emulate this.
const NextComponent = nextExports.default;
act(() => {
- legacyRender(, container);
+ renderImplementation();
});
}
act(() => {
@@ -142,8 +139,8 @@ describe('Fast Refresh', () => {
`);
- let element = container.firstChild;
- expect(container.firstChild).not.toBe(null);
+ let element = getContainer().firstChild;
+ expect(getContainer().firstChild).not.toBe(null);
patch(`
function Parent() {
@@ -163,8 +160,8 @@ describe('Fast Refresh', () => {
`);
// State is preserved; this verifies that Fast Refresh is wired up.
- expect(container.firstChild).toBe(element);
- element = container.firstChild;
+ expect(getContainer().firstChild).toBe(element);
+ element = getContainer().firstChild;
patch(`
function Parent() {
@@ -184,7 +181,7 @@ describe('Fast Refresh', () => {
`);
// State is reset because hooks changed.
- expect(container.firstChild).not.toBe(element);
+ expect(getContainer().firstChild).not.toBe(element);
});
// @reactVersion >= 16.9