@@ -50,13 +50,18 @@ describe('static props', () => {
5050 name : PropTypes . string . isRequired ,
5151 } ;
5252
53- const ViewComp = view ( MyCustomCompName ) ;
53+ const ViewComp = MyCustomCompName ;
5454
5555 const errorSpy = jest
5656 . 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 ) ;
6065 render ( < ViewComp number = "Bob" /> ) ;
6166 expect ( errorSpy ) . toHaveBeenCalled ( ) ;
6267 errorSpy . mockRestore ( ) ;
@@ -75,9 +80,13 @@ describe('static props', () => {
7580
7681 const errorSpy = jest
7782 . 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+ } ) ;
8190 render ( < ViewComp number = "Bob" /> ) ;
8291 expect ( errorSpy ) . toHaveBeenCalled ( ) ;
8392 errorSpy . mockRestore ( ) ;
0 commit comments