Skip to content

Commit 063c042

Browse files
author
Jack Pope
committed
Enable RTR create warning
1 parent 147a267 commit 063c042

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

packages/shared/ReactFeatureFlags.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ export const enableInfiniteRenderLoopDetection = true;
187187
// during element creation.
188188
export const enableRefAsProp = __NEXT_MAJOR__;
189189

190-
// Not ready to break experimental yet.
191-
// Needs more internal cleanup
190+
// Set to next major in ReactFeatureFlags.test-renderer
192191
// Warn on any usage of ReactTestRenderer
193192
export const enableReactTestRendererWarning = false;
194193

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const enableInfiniteRenderLoopDetection = false;
9898
// flags should be handled by the Fiber config.
9999
const __NEXT_MAJOR__ = __EXPERIMENTAL__;
100100
export const enableRefAsProp = __NEXT_MAJOR__;
101-
export const enableReactTestRendererWarning = false;
101+
export const enableReactTestRendererWarning = __NEXT_MAJOR__;
102102

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

scripts/jest/setupTests.js

+6
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.
+11
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)