diff --git a/packages/react-devtools-shared/src/__tests__/console-test.js b/packages/react-devtools-shared/src/__tests__/console-test.js
index e70c8e3a0afa8..e2674b10f3526 100644
--- a/packages/react-devtools-shared/src/__tests__/console-test.js
+++ b/packages/react-devtools-shared/src/__tests__/console-test.js
@@ -7,13 +7,12 @@
* @flow
*/
-import {normalizeCodeLocInfo} from './utils';
+import {getVersionedRenderImplementation, normalizeCodeLocInfo} from './utils';
let React;
let ReactDOMClient;
let act;
let fakeConsole;
-let legacyRender;
let mockError;
let mockInfo;
let mockGroup;
@@ -67,9 +66,10 @@ describe('console', () => {
const utils = require('./utils');
act = utils.act;
- legacyRender = utils.legacyRender;
});
+ const {render} = getVersionedRenderImplementation();
+
// @reactVersion >=18.0
it('should not patch console methods that are not explicitly overridden', () => {
expect(fakeConsole.error).not.toBe(mockError);
@@ -185,7 +185,7 @@ describe('console', () => {
return null;
};
- act(() => legacyRender(, document.createElement('div')));
+ act(() => render());
expect(mockWarn).toHaveBeenCalledTimes(1);
expect(mockWarn.mock.calls[0]).toHaveLength(1);
@@ -215,7 +215,7 @@ describe('console', () => {
return null;
};
- act(() => legacyRender(, document.createElement('div')));
+ act(() => render());
expect(mockLog).toHaveBeenCalledTimes(1);
expect(mockLog.mock.calls[0]).toHaveLength(1);
@@ -256,7 +256,7 @@ describe('console', () => {
return null;
};
- act(() => legacyRender(, document.createElement('div')));
+ act(() => render());
expect(mockLog).toHaveBeenCalledTimes(2);
expect(mockLog.mock.calls[0]).toHaveLength(1);
@@ -313,9 +313,8 @@ describe('console', () => {
}
}
- const container = document.createElement('div');
- act(() => legacyRender(, container));
- act(() => legacyRender(, container));
+ act(() => render());
+ act(() => render());
expect(mockLog).toHaveBeenCalledTimes(2);
expect(mockLog.mock.calls[0]).toHaveLength(1);
@@ -367,7 +366,7 @@ describe('console', () => {
}
}
- act(() => legacyRender(, document.createElement('div')));
+ act(() => render());
expect(mockLog).toHaveBeenCalledTimes(1);
expect(mockLog.mock.calls[0]).toHaveLength(1);
@@ -396,7 +395,7 @@ describe('console', () => {
return null;
};
- act(() => legacyRender(, document.createElement('div')));
+ act(() => render());
expect(mockWarn).toHaveBeenCalledTimes(1);
expect(mockWarn.mock.calls[0]).toHaveLength(1);
@@ -410,7 +409,7 @@ describe('console', () => {
breakOnConsoleErrors: false,
showInlineWarningsAndErrors: false,
});
- act(() => legacyRender(, document.createElement('div')));
+ act(() => render());
expect(mockWarn).toHaveBeenCalledTimes(2);
expect(mockWarn.mock.calls[1]).toHaveLength(2);
@@ -457,7 +456,7 @@ describe('console', () => {
return null;
};
- act(() => legacyRender(, document.createElement('div')));
+ act(() => render());
expect(mockLog).toHaveBeenCalledTimes(1);
expect(mockLog.mock.calls[0]).toHaveLength(1);
@@ -483,7 +482,7 @@ describe('console', () => {
return null;
};
- act(() => legacyRender(, document.createElement('div')));
+ act(() => render());
expect(mockWarn).toHaveBeenCalledTimes(1);
expect(mockWarn.mock.calls[0][0]).toBe('Symbol:');
@@ -824,7 +823,6 @@ describe('console error', () => {
const utils = require('./utils');
act = utils.act;
- legacyRender = utils.legacyRender;
});
// @reactVersion >=18.0