Skip to content

Commit 9cfbf61

Browse files
author
Jack Pope
committed
Enable RTR create warning
1 parent a493901 commit 9cfbf61

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ beforeEach(() => {
129129
jest.useFakeTimers();
130130

131131
// Use utils.js#withErrorsOrWarningsIgnored instead of directly mutating this array.
132-
global._ignoredErrorOrWarningMessages = [];
132+
global._ignoredErrorOrWarningMessages = [
133+
'react-test-renderer is deprecated.',
134+
];
133135
function shouldIgnoreConsoleErrorOrWarn(args) {
134136
let firstArg = args[0];
135137
if (

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,14 +2586,14 @@ describe('TreeListContext', () => {
25862586
utils.act(() => TestRenderer.create(<Contexts />));
25872587

25882588
expect(store).toMatchInlineSnapshot(`
2589-
✕ 1, ⚠ 0
2589+
✕ 1, ⚠ 1
25902590
[root]
25912591
<ErrorBoundary> ✕
25922592
`);
25932593

25942594
selectNextErrorOrWarning();
25952595
expect(state).toMatchInlineSnapshot(`
2596-
✕ 1, ⚠ 0
2596+
✕ 1, ⚠ 1
25972597
[root]
25982598
→ <ErrorBoundary> ✕
25992599
`);
@@ -2648,14 +2648,14 @@ describe('TreeListContext', () => {
26482648
utils.act(() => TestRenderer.create(<Contexts />));
26492649

26502650
expect(store).toMatchInlineSnapshot(`
2651-
✕ 1, ⚠ 0
2651+
✕ 1, ⚠ 1
26522652
[root]
26532653
<ErrorBoundary> ✕
26542654
`);
26552655

26562656
selectNextErrorOrWarning();
26572657
expect(state).toMatchInlineSnapshot(`
2658-
✕ 1, ⚠ 0
2658+
✕ 1, ⚠ 1
26592659
[root]
26602660
→ <ErrorBoundary> ✕
26612661
`);
@@ -2705,15 +2705,15 @@ describe('TreeListContext', () => {
27052705
utils.act(() => TestRenderer.create(<Contexts />));
27062706

27072707
expect(store).toMatchInlineSnapshot(`
2708-
✕ 2, ⚠ 0
2708+
✕ 2, ⚠ 1
27092709
[root]
27102710
▾ <ErrorBoundary> ✕
27112711
<Child> ✕
27122712
`);
27132713

27142714
selectNextErrorOrWarning();
27152715
expect(state).toMatchInlineSnapshot(`
2716-
✕ 2, ⚠ 0
2716+
✕ 2, ⚠ 1
27172717
[root]
27182718
→ ▾ <ErrorBoundary> ✕
27192719
<Child> ✕

packages/shared/ReactFeatureFlags.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,8 @@ export const enableInfiniteRenderLoopDetection = true;
190190
export const enableRefAsProp = __NEXT_MAJOR__;
191191
export const disableStringRefs = __NEXT_MAJOR__;
192192

193-
// Not ready to break experimental yet.
194-
// Needs more internal cleanup
195193
// Warn on any usage of ReactTestRenderer
196-
export const enableReactTestRendererWarning = false;
194+
export const enableReactTestRendererWarning = __NEXT_MAJOR__;
197195

198196
// Disables legacy mode
199197
// This allows us to land breaking changes to remove legacy mode APIs in experimental builds

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ export const enableInfiniteRenderLoopDetection = false;
9595
const __NEXT_MAJOR__ = __EXPERIMENTAL__;
9696
export const enableRefAsProp = __NEXT_MAJOR__;
9797
export const disableStringRefs = __NEXT_MAJOR__;
98-
export const enableReactTestRendererWarning = false;
9998
export const enableBigIntSupport = __NEXT_MAJOR__;
10099
export const disableLegacyMode = __NEXT_MAJOR__;
101100
export const disableLegacyContext = __NEXT_MAJOR__;
102101
export const enableNewBooleanProps = __NEXT_MAJOR__;
103102
export const disableModulePatternComponents = __NEXT_MAJOR__;
103+
export const enableReactTestRendererWarning = __NEXT_MAJOR__;
104104

105105
// Flow magic to verify the exports of this file match the original version.
106106
((((null: any): ExportsType): FeatureFlagsType): ExportsType);

scripts/jest/setupTests.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const chalk = require('chalk');
44
const util = require('util');
55
const shouldIgnoreConsoleError = require('./shouldIgnoreConsoleError');
6+
const shouldIgnoreConsoleWarn = require('./shouldIgnoreConsoleWarn');
67
const {getTestFlags} = require('./TestFlags');
78

89
if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
@@ -71,6 +72,11 @@ if (process.env.REACT_CLASS_EQUIVALENCE_TEST) {
7172
return;
7273
}
7374

75+
// Ignore certain React warnings causing test failures
76+
if (methodName === 'warn' && shouldIgnoreConsoleWarn(format)) {
77+
return;
78+
}
79+
7480
// Capture the call stack now so we can warn about it later.
7581
// The call stack has helpful information for the test author.
7682
// Don't throw yet though b'c it might be accidentally caught and suppressed.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
module.exports = function shouldIgnoreConsoleWarn(format) {
4+
if (typeof format === 'string') {
5+
if (format.indexOf('Warning: react-test-renderer is deprecated.') === 0) {
6+
return true;
7+
}
8+
}
9+
10+
return false;
11+
};

0 commit comments

Comments
 (0)