@@ -90,24 +90,37 @@ describe('ReactDOMFizzServer', () => {
90
90
} ) ;
91
91
92
92
function expectErrors ( errorsArr , toBeDevArr , toBeProdArr ) {
93
+ const mappedErrows = errorsArr . map ( error => {
94
+ if ( error . componentStack ) {
95
+ return [
96
+ error . message ,
97
+ error . hash ,
98
+ normalizeCodeLocInfo ( error . componentStack ) ,
99
+ ] ;
100
+ } else if ( error . hash ) {
101
+ return [ error . message , error . hash ] ;
102
+ }
103
+ return error . message ;
104
+ } ) ;
93
105
if ( __DEV__ ) {
94
- expect ( errorsArr . map ( error => normalizeCodeLocInfo ( error ) ) ) . toEqual (
95
- toBeDevArr . map ( error => {
96
- if ( typeof error === 'string' || error instanceof String ) {
97
- return error ;
98
- }
99
- let str = JSON . stringify ( error ) . replace ( / \\ n / g, '\n' ) ;
100
- // this gets stripped away by normalizeCodeLocInfo...
101
- // Kind of hacky but lets strip it away here too just so they match...
102
- // easier than fixing the regex to account for this edge case
103
- if ( str . endsWith ( 'at **)"}' ) ) {
104
- str = str . replace ( / a t \* \* \) \" } $ / , 'at **)' ) ;
105
- }
106
- return str ;
107
- } ) ,
106
+ expect ( mappedErrows ) . toEqual (
107
+ toBeDevArr ,
108
+ // .map(([errorMessage, errorHash, errorComponentStack]) => {
109
+ // if (typeof error === 'string' || error instanceof String) {
110
+ // return error;
111
+ // }
112
+ // let str = JSON.stringify(error).replace(/\\n/g, '\n');
113
+ // // this gets stripped away by normalizeCodeLocInfo...
114
+ // // Kind of hacky but lets strip it away here too just so they match...
115
+ // // easier than fixing the regex to account for this edge case
116
+ // if (str.endsWith('at **)" }')) {
117
+ // str = str.replace(/at \*\*\)\" }$/, 'at **)');
118
+ // }
119
+ // return str;
120
+ // }),
108
121
) ;
109
122
} else {
110
- expect ( errorsArr ) . toEqual ( toBeProdArr ) ;
123
+ expect ( mappedErrows ) . toEqual ( toBeProdArr ) ;
111
124
}
112
125
}
113
126
@@ -453,7 +466,7 @@ describe('ReactDOMFizzServer', () => {
453
466
// Attempt to hydrate the content.
454
467
ReactDOMClient . hydrateRoot ( container , < App isClient = { true } /> , {
455
468
onRecoverableError ( error ) {
456
- errors . push ( error . message ) ;
469
+ errors . push ( error ) ;
457
470
} ,
458
471
} ) ;
459
472
} ;
@@ -501,12 +514,18 @@ describe('ReactDOMFizzServer', () => {
501
514
expectErrors (
502
515
errors ,
503
516
[
504
- theError . message +
505
- '\nServer Error Hash: ' +
506
- expectedHash +
517
+ [
518
+ theError . message ,
519
+ expectedHash ,
507
520
componentStack ( [ 'Lazy' , 'Suspense' , 'div' , 'App' ] ) ,
521
+ ] ,
522
+ ] ,
523
+ [
524
+ [
525
+ 'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.' ,
526
+ expectedHash ,
527
+ ] ,
508
528
] ,
509
- [ expectedHash ] ,
510
529
) ;
511
530
512
531
// The client rendered HTML is now in place.
@@ -590,7 +609,7 @@ describe('ReactDOMFizzServer', () => {
590
609
// Attempt to hydrate the content.
591
610
ReactDOMClient . hydrateRoot ( container , < App isClient = { true } /> , {
592
611
onRecoverableError ( error ) {
593
- errors . push ( error . message ) ;
612
+ errors . push ( error ) ;
594
613
} ,
595
614
} ) ;
596
615
Scheduler . unstable_flushAll ( ) ;
@@ -615,12 +634,18 @@ describe('ReactDOMFizzServer', () => {
615
634
expectErrors (
616
635
errors ,
617
636
[
618
- theError . message +
619
- '\nServer Error Hash: ' +
620
- expectedHash +
637
+ [
638
+ theError . message ,
639
+ expectedHash ,
621
640
componentStack ( [ '~lazy-element~' , 'Suspense' , 'div' , 'App' ] ) ,
641
+ ] ,
642
+ ] ,
643
+ [
644
+ [
645
+ 'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.' ,
646
+ expectedHash ,
647
+ ] ,
622
648
] ,
623
- [ expectedHash ] ,
624
649
) ;
625
650
626
651
// The client rendered HTML is now in place.
@@ -681,7 +706,7 @@ describe('ReactDOMFizzServer', () => {
681
706
// Attempt to hydrate the content.
682
707
ReactDOMClient . hydrateRoot ( container , < App isClient = { true } /> , {
683
708
onRecoverableError ( error ) {
684
- errors . push ( error . message ) ;
709
+ errors . push ( error ) ;
685
710
} ,
686
711
} ) ;
687
712
Scheduler . unstable_flushAll ( ) ;
@@ -691,12 +716,18 @@ describe('ReactDOMFizzServer', () => {
691
716
expectErrors (
692
717
errors ,
693
718
[
694
- theError . message +
695
- '\nServer Error Hash: ' +
696
- expectedHash +
719
+ [
720
+ theError . message ,
721
+ expectedHash ,
697
722
componentStack ( [ 'Erroring' , 'Suspense' , 'div' , 'App' ] ) ,
723
+ ] ,
724
+ ] ,
725
+ [
726
+ [
727
+ 'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.' ,
728
+ expectedHash ,
729
+ ] ,
698
730
] ,
699
- [ expectedHash ] ,
700
731
) ;
701
732
} ) ;
702
733
@@ -744,7 +775,7 @@ describe('ReactDOMFizzServer', () => {
744
775
// Attempt to hydrate the content.
745
776
ReactDOMClient . hydrateRoot ( container , < App isClient = { true } /> , {
746
777
onRecoverableError ( error ) {
747
- errors . push ( error . message ) ;
778
+ errors . push ( error ) ;
748
779
} ,
749
780
} ) ;
750
781
Scheduler . unstable_flushAll ( ) ;
@@ -764,12 +795,18 @@ describe('ReactDOMFizzServer', () => {
764
795
expectErrors (
765
796
errors ,
766
797
[
767
- theError . message +
768
- '\nServer Error Hash: ' +
769
- expectedHash +
798
+ [
799
+ theError . message ,
800
+ expectedHash ,
770
801
componentStack ( [ 'Lazy' , 'Suspense' , 'div' , 'App' ] ) ,
802
+ ] ,
803
+ ] ,
804
+ [
805
+ [
806
+ 'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.' ,
807
+ expectedHash ,
808
+ ] ,
771
809
] ,
772
- [ expectedHash ] ,
773
810
) ;
774
811
775
812
// The client rendered HTML is now in place.
@@ -1057,7 +1094,7 @@ describe('ReactDOMFizzServer', () => {
1057
1094
// Attempt to hydrate the content.
1058
1095
ReactDOMClient . hydrateRoot ( container , < App /> , {
1059
1096
onRecoverableError ( error ) {
1060
- errors . push ( error . message ) ;
1097
+ errors . push ( error ) ;
1061
1098
} ,
1062
1099
} ) ;
1063
1100
Scheduler . unstable_flushAll ( ) ;
@@ -1761,7 +1798,7 @@ describe('ReactDOMFizzServer', () => {
1761
1798
// Attempt to hydrate the content.
1762
1799
ReactDOMClient . hydrateRoot ( container , < App isClient = { true } /> , {
1763
1800
onRecoverableError ( error ) {
1764
- errors . push ( error . message ) ;
1801
+ errors . push ( error ) ;
1765
1802
} ,
1766
1803
} ) ;
1767
1804
Scheduler . unstable_flushAll ( ) ;
@@ -1795,9 +1832,9 @@ describe('ReactDOMFizzServer', () => {
1795
1832
expectErrors (
1796
1833
errors ,
1797
1834
[
1798
- theError . message +
1799
- '\nServer Error Hash: ' +
1800
- expectedHash +
1835
+ [
1836
+ theError . message ,
1837
+ expectedHash ,
1801
1838
componentStack ( [
1802
1839
'AsyncText' ,
1803
1840
'h1' ,
@@ -1806,8 +1843,14 @@ describe('ReactDOMFizzServer', () => {
1806
1843
'Suspense' ,
1807
1844
'App' ,
1808
1845
] ) ,
1846
+ ] ,
1847
+ ] ,
1848
+ [
1849
+ [
1850
+ 'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.' ,
1851
+ expectedHash ,
1852
+ ] ,
1809
1853
] ,
1810
- [ expectedHash ] ,
1811
1854
) ;
1812
1855
1813
1856
// The client rendered HTML is now in place.
@@ -3114,8 +3157,6 @@ describe('ReactDOMFizzServer', () => {
3114
3157
} ) ;
3115
3158
//@gate experimental
3116
3159
it ( 'escapes such that attributes cannot be masked' , async ( ) => {
3117
- window . __outlet = { } ;
3118
-
3119
3160
const dangerousErrorString = '" data-msg="bad message" data-foo="' ;
3120
3161
const theError = new Error ( dangerousErrorString ) ;
3121
3162
@@ -3154,7 +3195,7 @@ describe('ReactDOMFizzServer', () => {
3154
3195
const errors = [ ] ;
3155
3196
ReactDOMClient . hydrateRoot ( container , < App isClient = { true } /> , {
3156
3197
onRecoverableError ( error ) {
3157
- errors . push ( error . message ) ;
3198
+ errors . push ( error ) ;
3158
3199
} ,
3159
3200
} ) ;
3160
3201
expect ( Scheduler ) . toFlushAndYield ( [ ] ) ;
@@ -3163,12 +3204,18 @@ describe('ReactDOMFizzServer', () => {
3163
3204
expectErrors (
3164
3205
errors ,
3165
3206
[
3166
- theError . message +
3167
- '\nServer Error Hash: ' +
3168
- expectedHash +
3207
+ [
3208
+ theError . message ,
3209
+ expectedHash ,
3169
3210
componentStack ( [ 'Erroring' , 'Suspense' , 'div' , 'App' ] ) ,
3211
+ ] ,
3212
+ ] ,
3213
+ [
3214
+ [
3215
+ 'The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.' ,
3216
+ expectedHash ,
3217
+ ] ,
3170
3218
] ,
3171
- [ expectedHash ] ,
3172
3219
) ;
3173
3220
} ) ;
3174
3221
} ) ;
0 commit comments