@@ -50,13 +50,18 @@ describe('static props', () => {
50
50
name : PropTypes . string . isRequired ,
51
51
} ;
52
52
53
- const ViewComp = view ( MyCustomCompName ) ;
53
+ const ViewComp = MyCustomCompName ;
54
54
55
55
const errorSpy = jest
56
56
. spyOn ( console , 'error' )
57
- . mockImplementation ( ( message ) =>
58
- expect ( message . indexOf ( 'Failed prop type' ) ) . not . toBe ( - 1 ) ,
59
- ) ;
57
+ . mockImplementation ( ( warning , prop , error ) => {
58
+ expect ( warning ) . toBe ( 'Warning: Failed %s type: %s%s' ) ;
59
+ expect ( prop ) . toBe ( 'prop' ) ;
60
+ expect ( error ) . toBe (
61
+ 'The prop `name` is marked as required in `MyCustomCompName`, but its value is `undefined`.' ,
62
+ ) ;
63
+ } ) ;
64
+ expect ( 1 ) . toBe ( 1 ) ;
60
65
render ( < ViewComp number = "Bob" /> ) ;
61
66
expect ( errorSpy ) . toHaveBeenCalled ( ) ;
62
67
errorSpy . mockRestore ( ) ;
@@ -75,9 +80,13 @@ describe('static props', () => {
75
80
76
81
const errorSpy = jest
77
82
. spyOn ( console , 'error' )
78
- . mockImplementation ( ( message ) =>
79
- expect ( message . indexOf ( 'Failed prop type' ) ) . not . toBe ( - 1 ) ,
80
- ) ;
83
+ . mockImplementation ( ( warning , prop , error ) => {
84
+ expect ( warning ) . toBe ( 'Warning: Failed %s type: %s%s' ) ;
85
+ expect ( prop ) . toBe ( 'prop' ) ;
86
+ expect ( error ) . toBe (
87
+ 'Invalid prop `number` of type `string` supplied to `MyCustomCompName`, expected `number`.' ,
88
+ ) ;
89
+ } ) ;
81
90
render ( < ViewComp number = "Bob" /> ) ;
82
91
expect ( errorSpy ) . toHaveBeenCalled ( ) ;
83
92
errorSpy . mockRestore ( ) ;
0 commit comments