Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions packages/react-devtools-shared/src/__tests__/console-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('console', () => {
return null;
};

act(() => legacyRender(<Child />, document.createElement('div')));
act(() => render(<Child />));

expect(mockWarn).toHaveBeenCalledTimes(1);
expect(mockWarn.mock.calls[0]).toHaveLength(1);
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('console', () => {
return null;
};

act(() => legacyRender(<Parent />, document.createElement('div')));
act(() => render(<Parent />));

expect(mockLog).toHaveBeenCalledTimes(1);
expect(mockLog.mock.calls[0]).toHaveLength(1);
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('console', () => {
return null;
};

act(() => legacyRender(<Parent />, document.createElement('div')));
act(() => render(<Parent />));

expect(mockLog).toHaveBeenCalledTimes(2);
expect(mockLog.mock.calls[0]).toHaveLength(1);
Expand Down Expand Up @@ -313,9 +313,8 @@ describe('console', () => {
}
}

const container = document.createElement('div');
act(() => legacyRender(<Parent />, container));
act(() => legacyRender(<Parent />, container));
act(() => render(<Parent />));
act(() => render(<Parent />));

expect(mockLog).toHaveBeenCalledTimes(2);
expect(mockLog.mock.calls[0]).toHaveLength(1);
Expand Down Expand Up @@ -367,7 +366,7 @@ describe('console', () => {
}
}

act(() => legacyRender(<Parent />, document.createElement('div')));
act(() => render(<Parent />));

expect(mockLog).toHaveBeenCalledTimes(1);
expect(mockLog.mock.calls[0]).toHaveLength(1);
Expand Down Expand Up @@ -396,7 +395,7 @@ describe('console', () => {
return null;
};

act(() => legacyRender(<Child />, document.createElement('div')));
act(() => render(<Child />));

expect(mockWarn).toHaveBeenCalledTimes(1);
expect(mockWarn.mock.calls[0]).toHaveLength(1);
Expand All @@ -410,7 +409,7 @@ describe('console', () => {
breakOnConsoleErrors: false,
showInlineWarningsAndErrors: false,
});
act(() => legacyRender(<Child />, document.createElement('div')));
act(() => render(<Child />));

expect(mockWarn).toHaveBeenCalledTimes(2);
expect(mockWarn.mock.calls[1]).toHaveLength(2);
Expand Down Expand Up @@ -457,7 +456,7 @@ describe('console', () => {
return null;
};

act(() => legacyRender(<Parent />, document.createElement('div')));
act(() => render(<Parent />));

expect(mockLog).toHaveBeenCalledTimes(1);
expect(mockLog.mock.calls[0]).toHaveLength(1);
Expand All @@ -483,7 +482,7 @@ describe('console', () => {
return null;
};

act(() => legacyRender(<Component />, document.createElement('div')));
act(() => render(<Component />));

expect(mockWarn).toHaveBeenCalledTimes(1);
expect(mockWarn.mock.calls[0][0]).toBe('Symbol:');
Expand Down Expand Up @@ -824,7 +823,6 @@ describe('console error', () => {

const utils = require('./utils');
act = utils.act;
legacyRender = utils.legacyRender;
});

// @reactVersion >=18.0
Expand Down