Skip to content

Commit 0364e97

Browse files
committed
Ignore both versions in DevTools test that might assert on multiple React
1 parent 5d7b147 commit 0364e97

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2551,7 +2551,7 @@ describe('InspectedElement', () => {
25512551
};
25522552

25532553
await withErrorsOrWarningsIgnored(
2554-
['Warning: Each child in a list should have a unique "key" prop.'],
2554+
['Each child in a list should have a unique "key" prop.'],
25552555
async () => {
25562556
await utils.actAsync(() =>
25572557
render(<Example repeatWarningCount={1} />),

packages/react-devtools-shared/src/__tests__/setupTests.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,22 @@ beforeEach(() => {
154154

155155
const originalConsoleError = console.error;
156156
console.error = (...args) => {
157-
const firstArg = args[0];
158-
if (
159-
firstArg === 'Warning: React instrumentation encountered an error: %s'
160-
) {
157+
let firstArg = args[0];
158+
if (typeof firstArg === 'string' && firstArg.startsWith('Warning: ')) {
159+
// Older React versions might use the Warning: prefix. I'm not sure
160+
// if they use this code path.
161+
firstArg = firstArg.slice(9);
162+
}
163+
if (firstArg === 'React instrumentation encountered an error: %s') {
161164
// Rethrow errors from React.
162165
throw args[1];
163166
} else if (
164167
typeof firstArg === 'string' &&
165-
(firstArg.startsWith(
166-
"Warning: It looks like you're using the wrong act()",
167-
) ||
168+
(firstArg.startsWith("It looks like you're using the wrong act()") ||
168169
firstArg.startsWith(
169-
'Warning: The current testing environment is not configured to support act',
170+
'The current testing environment is not configured to support act',
170171
) ||
171-
firstArg.startsWith(
172-
'Warning: You seem to have overlapping act() calls',
173-
))
172+
firstArg.startsWith('You seem to have overlapping act() calls'))
174173
) {
175174
// DevTools intentionally wraps updates with acts from both DOM and test-renderer,
176175
// since test updates are expected to impact both renderers.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,7 @@ describe('Store', () => {
19271927
}
19281928

19291929
withErrorsOrWarningsIgnored(
1930-
['Warning: Each child in a list should have a unique "key" prop'],
1930+
['Each child in a list should have a unique "key" prop'],
19311931
() => {
19321932
act(() => render(<Example />));
19331933
},
@@ -1952,7 +1952,7 @@ describe('Store', () => {
19521952
}
19531953

19541954
withErrorsOrWarningsIgnored(
1955-
['Warning: Each child in a list should have a unique "key" prop'],
1955+
['Each child in a list should have a unique "key" prop'],
19561956
() => {
19571957
act(() => render(<Example />));
19581958
},

packages/react-devtools-shell/src/app/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,18 @@ ignoreErrors([
3232
'Warning: %s is deprecated in StrictMode.', // findDOMNode
3333
'Warning: ReactDOM.render was removed in React 19',
3434
'Warning: react-test-renderer is deprecated',
35+
// Ignore prefixed and not prefixed since I don't know which
36+
// React versions are being tested by this code.
37+
'Legacy context API',
38+
'Unsafe lifecycle methods',
39+
'%s is deprecated in StrictMode.', // findDOMNode
40+
'ReactDOM.render was removed in React 19',
41+
'react-test-renderer is deprecated',
42+
]);
43+
ignoreWarnings([
44+
'Warning: componentWillReceiveProps has been renamed',
45+
'componentWillReceiveProps has been renamed'
3546
]);
36-
ignoreWarnings(['Warning: componentWillReceiveProps has been renamed']);
3747
ignoreLogs([]);
3848

3949
const unmountFunctions: Array<() => void | boolean> = [];

0 commit comments

Comments
 (0)