Skip to content

Commit 631bb9e

Browse files
committed
chore: use versioned render in FastRefreshDevToolsIntegration test
1 parent e51cda5 commit 631bb9e

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

packages/react-devtools-shared/src/__tests__/FastRefreshDevToolsIntegration-test.js

+12-15
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,20 @@
77
* @flow
88
*/
99

10+
import {getVersionedRenderImplementation} from './utils';
11+
1012
describe('Fast Refresh', () => {
1113
let React;
1214
let ReactFreshRuntime;
1315
let act;
1416
let babel;
15-
let container;
1617
let exportsObj;
1718
let freshPlugin;
18-
let legacyRender;
1919
let store;
2020
let withErrorsOrWarningsIgnored;
2121

22-
afterEach(() => {
23-
jest.resetModules();
24-
});
25-
2622
beforeEach(() => {
2723
exportsObj = undefined;
28-
container = document.createElement('div');
2924

3025
babel = require('@babel/core');
3126
freshPlugin = require('react-refresh/babel');
@@ -39,10 +34,12 @@ describe('Fast Refresh', () => {
3934

4035
const utils = require('./utils');
4136
act = utils.act;
42-
legacyRender = utils.legacyRender;
4337
withErrorsOrWarningsIgnored = utils.withErrorsOrWarningsIgnored;
4438
});
4539

40+
const {render: renderImplementation, getContainer} =
41+
getVersionedRenderImplementation();
42+
4643
function execute(source) {
4744
const compiled = babel.transform(source, {
4845
babelrc: false,
@@ -73,7 +70,7 @@ describe('Fast Refresh', () => {
7370
function render(source) {
7471
const Component = execute(source);
7572
act(() => {
76-
legacyRender(<Component />, container);
73+
renderImplementation(<Component />);
7774
});
7875
// Module initialization shouldn't be counted as a hot update.
7976
expect(ReactFreshRuntime.performReactRefresh()).toBe(null);
@@ -98,7 +95,7 @@ describe('Fast Refresh', () => {
9895
// Here, we'll just force a re-render using the newer type to emulate this.
9996
const NextComponent = nextExports.default;
10097
act(() => {
101-
legacyRender(<NextComponent />, container);
98+
renderImplementation(<NextComponent />);
10299
});
103100
}
104101
act(() => {
@@ -142,8 +139,8 @@ describe('Fast Refresh', () => {
142139
<Child key="A">
143140
`);
144141

145-
let element = container.firstChild;
146-
expect(container.firstChild).not.toBe(null);
142+
let element = getContainer().firstChild;
143+
expect(getContainer().firstChild).not.toBe(null);
147144

148145
patch(`
149146
function Parent() {
@@ -163,8 +160,8 @@ describe('Fast Refresh', () => {
163160
`);
164161

165162
// State is preserved; this verifies that Fast Refresh is wired up.
166-
expect(container.firstChild).toBe(element);
167-
element = container.firstChild;
163+
expect(getContainer().firstChild).toBe(element);
164+
element = getContainer().firstChild;
168165

169166
patch(`
170167
function Parent() {
@@ -184,7 +181,7 @@ describe('Fast Refresh', () => {
184181
`);
185182

186183
// State is reset because hooks changed.
187-
expect(container.firstChild).not.toBe(element);
184+
expect(getContainer().firstChild).not.toBe(element);
188185
});
189186

190187
// @reactVersion >= 16.9

0 commit comments

Comments
 (0)