File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,19 @@ beforeEach(() => {
28
28
sinon . stub ( console , 'error' ) . callsFake ( ( msg , ...args ) => {
29
29
let expected = false ;
30
30
31
+ // When using the new JSX transform, React uses a different checkPropTypes
32
+ // function that exists within react-jsx-dev-runtime.development.js that
33
+ // sends in a string message with args. In contrast, without the JSX transform,
34
+ // React (react.development.js) uses checkPropTypes from the prop-types package
35
+ // and this formats the string prior to calling console.error.
36
+ // We're going to need to format the string ourselves and check it.
37
+ let formattedStr = msg ;
38
+ if ( args . length ) {
39
+ formattedStr = Util . format ( msg , ...args ) ;
40
+ }
41
+
31
42
console . error . expected . forEach ( ( about ) => {
32
- if ( msg . indexOf ( about ) !== - 1 ) {
43
+ if ( formattedStr . indexOf ( about ) !== - 1 ) {
33
44
console . error . warned [ about ] = true ;
34
45
expected = true ;
35
46
}
@@ -40,7 +51,7 @@ beforeEach(() => {
40
51
}
41
52
42
53
console . error . threw = true ;
43
- throw new Error ( Util . format ( msg , ... args ) ) ;
54
+ throw new Error ( formattedStr ) ;
44
55
} ) ;
45
56
46
57
console . error . expected = [ ] ;
You can’t perform that action at this time.
0 commit comments