@@ -871,5 +871,71 @@ describe('ReactDOMServerIntegration', () => {
871
871
: '' ) ,
872
872
) ;
873
873
} ) ;
874
+
875
+ describe ( 'badly-typed elements' , function ( ) {
876
+ itThrowsWhenRendering (
877
+ 'object' ,
878
+ async render => {
879
+ let EmptyComponent = { } ;
880
+ expect ( ( ) => {
881
+ EmptyComponent = < EmptyComponent /> ;
882
+ } ) . toWarnDev (
883
+ 'Warning: React.createElement: type is invalid -- expected a string ' +
884
+ '(for built-in components) or a class/function (for composite ' +
885
+ 'components) but got: object. You likely forgot to export your ' +
886
+ "component from the file it's defined in, or you might have mixed up " +
887
+ 'default and named imports.' ,
888
+ ) ;
889
+ await render ( EmptyComponent ) ;
890
+ } ,
891
+ 'Element type is invalid: expected a string (for built-in components) or a class/function ' +
892
+ '(for composite components) but got: object.' +
893
+ ( __DEV__
894
+ ? " You likely forgot to export your component from the file it's defined in, " +
895
+ 'or you might have mixed up default and named imports.'
896
+ : '' ) ,
897
+ ) ;
898
+
899
+ itThrowsWhenRendering (
900
+ 'null' ,
901
+ async render => {
902
+ let NullComponent = null ;
903
+ expect ( ( ) => {
904
+ NullComponent = < NullComponent /> ;
905
+ } ) . toWarnDev (
906
+ 'Warning: React.createElement: type is invalid -- expected a string ' +
907
+ '(for built-in components) or a class/function (for composite ' +
908
+ 'components) but got: null.' ,
909
+ ) ;
910
+ await render ( NullComponent ) ;
911
+ } ,
912
+ 'Element type is invalid: expected a string (for built-in components) or a class/function ' +
913
+ '(for composite components) but got: null' ,
914
+ ) ;
915
+
916
+ itThrowsWhenRendering (
917
+ 'undefined' ,
918
+ async render => {
919
+ let UndefinedComponent = undefined ;
920
+ expect ( ( ) => {
921
+ UndefinedComponent = < UndefinedComponent /> ;
922
+ } ) . toWarnDev (
923
+ 'Warning: React.createElement: type is invalid -- expected a string ' +
924
+ '(for built-in components) or a class/function (for composite ' +
925
+ 'components) but got: undefined. You likely forgot to export your ' +
926
+ "component from the file it's defined in, or you might have mixed up " +
927
+ 'default and named imports.' ,
928
+ ) ;
929
+
930
+ await render ( UndefinedComponent ) ;
931
+ } ,
932
+ 'Element type is invalid: expected a string (for built-in components) or a class/function ' +
933
+ '(for composite components) but got: undefined.' +
934
+ ( __DEV__
935
+ ? " You likely forgot to export your component from the file it's defined in, " +
936
+ 'or you might have mixed up default and named imports.'
937
+ : '' ) ,
938
+ ) ;
939
+ } ) ;
874
940
} ) ;
875
941
} ) ;
0 commit comments