@@ -82,64 +82,25 @@ describe('ReactDOMConsoleErrorReporting', () => {
8282 ) ;
8383 } ) ;
8484
85- if ( __DEV__ ) {
86- expect ( windowOnError . mock . calls ) . toEqual ( [
87- [
88- // Reported because we're in a browser click event:
89- expect . objectContaining ( {
90- message : 'Boom' ,
91- } ) ,
92- ] ,
93- [
94- // This one is jsdom-only. Real browser deduplicates it.
95- // (In DEV, we have a nested event due to guarded callback.)
96- expect . objectContaining ( {
97- message : 'Boom' ,
98- } ) ,
99- ] ,
100- ] ) ;
101- expect ( console . error . mock . calls ) . toEqual ( [
102- [
103- // Reported because we're in a browser click event:
104- expect . objectContaining ( {
105- detail : expect . objectContaining ( {
106- message : 'Boom' ,
107- } ) ,
108- type : 'unhandled exception' ,
109- } ) ,
110- ] ,
111- [
112- // This one is jsdom-only. Real browser deduplicates it.
113- // (In DEV, we have a nested event due to guarded callback.)
114- expect . objectContaining ( {
115- detail : expect . objectContaining ( {
116- message : 'Boom' ,
117- } ) ,
118- type : 'unhandled exception' ,
119- } ) ,
120- ] ,
121- ] ) ;
122- } else {
123- expect ( windowOnError . mock . calls ) . toEqual ( [
124- [
125- // Reported because we're in a browser click event:
126- expect . objectContaining ( {
85+ expect ( windowOnError . mock . calls ) . toEqual ( [
86+ [
87+ // Reported because we're in a browser click event:
88+ expect . objectContaining ( {
89+ message : 'Boom' ,
90+ } ) ,
91+ ] ,
92+ ] ) ;
93+ expect ( console . error . mock . calls ) . toEqual ( [
94+ [
95+ // Reported because we're in a browser click event:
96+ expect . objectContaining ( {
97+ detail : expect . objectContaining ( {
12798 message : 'Boom' ,
12899 } ) ,
129- ] ,
130- ] ) ;
131- expect ( console . error . mock . calls ) . toEqual ( [
132- [
133- // Reported because we're in a browser click event:
134- expect . objectContaining ( {
135- detail : expect . objectContaining ( {
136- message : 'Boom' ,
137- } ) ,
138- type : 'unhandled exception' ,
139- } ) ,
140- ] ,
141- ] ) ;
142- }
100+ type : 'unhandled exception' ,
101+ } ) ,
102+ ] ,
103+ ] ) ;
143104
144105 // Check next render doesn't throw.
145106 windowOnError . mockReset ( ) ;
@@ -168,41 +129,8 @@ describe('ReactDOMConsoleErrorReporting', () => {
168129 } ) ;
169130
170131 if ( __DEV__ ) {
171- expect ( windowOnError . mock . calls ) . toEqual ( [
172- [
173- // Reported due to guarded callback:
174- expect . objectContaining ( {
175- message : 'Boom' ,
176- } ) ,
177- ] ,
178- [
179- // This is only duplicated with createRoot
180- // because it retries once with a sync render.
181- expect . objectContaining ( {
182- message : 'Boom' ,
183- } ) ,
184- ] ,
185- ] ) ;
132+ expect ( windowOnError . mock . calls ) . toEqual ( [ ] ) ;
186133 expect ( console . error . mock . calls ) . toEqual ( [
187- [
188- // Reported due to the guarded callback:
189- expect . objectContaining ( {
190- detail : expect . objectContaining ( {
191- message : 'Boom' ,
192- } ) ,
193- type : 'unhandled exception' ,
194- } ) ,
195- ] ,
196- [
197- // This is only duplicated with createRoot
198- // because it retries once with a sync render.
199- expect . objectContaining ( {
200- detail : expect . objectContaining ( {
201- message : 'Boom' ,
202- } ) ,
203- type : 'unhandled exception' ,
204- } ) ,
205- ] ,
206134 [
207135 // Addendum by React:
208136 expect . stringContaining (
@@ -254,41 +182,8 @@ describe('ReactDOMConsoleErrorReporting', () => {
254182 } ) ;
255183
256184 if ( __DEV__ ) {
257- expect ( windowOnError . mock . calls ) . toEqual ( [
258- [
259- // Reported due to guarded callback:
260- expect . objectContaining ( {
261- message : 'Boom' ,
262- } ) ,
263- ] ,
264- [
265- // This is only duplicated with createRoot
266- // because it retries once with a sync render.
267- expect . objectContaining ( {
268- message : 'Boom' ,
269- } ) ,
270- ] ,
271- ] ) ;
185+ expect ( windowOnError . mock . calls ) . toEqual ( [ ] ) ;
272186 expect ( console . error . mock . calls ) . toEqual ( [
273- [
274- // Reported by jsdom due to the guarded callback:
275- expect . objectContaining ( {
276- detail : expect . objectContaining ( {
277- message : 'Boom' ,
278- } ) ,
279- type : 'unhandled exception' ,
280- } ) ,
281- ] ,
282- [
283- // This is only duplicated with createRoot
284- // because it retries once with a sync render.
285- expect . objectContaining ( {
286- detail : expect . objectContaining ( {
287- message : 'Boom' ,
288- } ) ,
289- type : 'unhandled exception' ,
290- } ) ,
291- ] ,
292187 [
293188 // Addendum by React:
294189 expect . stringContaining (
@@ -340,24 +235,8 @@ describe('ReactDOMConsoleErrorReporting', () => {
340235 } ) ;
341236
342237 if ( __DEV__ ) {
343- expect ( windowOnError . mock . calls ) . toEqual ( [
344- [
345- // Reported due to guarded callback:
346- expect . objectContaining ( {
347- message : 'Boom' ,
348- } ) ,
349- ] ,
350- ] ) ;
238+ expect ( windowOnError . mock . calls ) . toEqual ( [ ] ) ;
351239 expect ( console . error . mock . calls ) . toEqual ( [
352- [
353- // Reported due to the guarded callback:
354- expect . objectContaining ( {
355- detail : expect . objectContaining ( {
356- message : 'Boom' ,
357- } ) ,
358- type : 'unhandled exception' ,
359- } ) ,
360- ] ,
361240 [
362241 // Addendum by React:
363242 expect . stringContaining (
@@ -412,24 +291,8 @@ describe('ReactDOMConsoleErrorReporting', () => {
412291 } ) ;
413292
414293 if ( __DEV__ ) {
415- expect ( windowOnError . mock . calls ) . toEqual ( [
416- [
417- // Reported due to guarded callback:
418- expect . objectContaining ( {
419- message : 'Boom' ,
420- } ) ,
421- ] ,
422- ] ) ;
294+ expect ( windowOnError . mock . calls ) . toEqual ( [ ] ) ;
423295 expect ( console . error . mock . calls ) . toEqual ( [
424- [
425- // Reported by jsdom due to the guarded callback:
426- expect . objectContaining ( {
427- detail : expect . objectContaining ( {
428- message : 'Boom' ,
429- } ) ,
430- type : 'unhandled exception' ,
431- } ) ,
432- ] ,
433296 [
434297 // Addendum by React:
435298 expect . stringContaining (
@@ -438,7 +301,7 @@ describe('ReactDOMConsoleErrorReporting', () => {
438301 ] ,
439302 ] ) ;
440303 } else {
441- // The top-level error was caught with try/catch, and there's no guarded callback,
304+ // The top-level error was caught with try/catch,
442305 // so in production we don't see an error event.
443306 expect ( windowOnError . mock . calls ) . toEqual ( [ ] ) ;
444307 expect ( console . error . mock . calls ) . toEqual ( [
@@ -481,24 +344,8 @@ describe('ReactDOMConsoleErrorReporting', () => {
481344 } ) ;
482345
483346 if ( __DEV__ ) {
484- expect ( windowOnError . mock . calls ) . toEqual ( [
485- [
486- // Reported due to guarded callback:
487- expect . objectContaining ( {
488- message : 'Boom' ,
489- } ) ,
490- ] ,
491- ] ) ;
347+ expect ( windowOnError . mock . calls ) . toEqual ( [ ] ) ;
492348 expect ( console . error . mock . calls ) . toEqual ( [
493- [
494- // Reported due to the guarded callback:
495- expect . objectContaining ( {
496- detail : expect . objectContaining ( {
497- message : 'Boom' ,
498- } ) ,
499- type : 'unhandled exception' ,
500- } ) ,
501- ] ,
502349 [
503350 // Addendum by React:
504351 expect . stringContaining (
@@ -507,7 +354,7 @@ describe('ReactDOMConsoleErrorReporting', () => {
507354 ] ,
508355 ] ) ;
509356 } else {
510- // The top-level error was caught with try/catch, and there's no guarded callback,
357+ // The top-level error was caught with try/catch,
511358 // so in production we don't see an error event.
512359 expect ( windowOnError . mock . calls ) . toEqual ( [ ] ) ;
513360 expect ( console . error . mock . calls ) . toEqual ( [
@@ -553,24 +400,8 @@ describe('ReactDOMConsoleErrorReporting', () => {
553400 } ) ;
554401
555402 if ( __DEV__ ) {
556- expect ( windowOnError . mock . calls ) . toEqual ( [
557- [
558- // Reported due to guarded callback:
559- expect . objectContaining ( {
560- message : 'Boom' ,
561- } ) ,
562- ] ,
563- ] ) ;
403+ expect ( windowOnError . mock . calls ) . toEqual ( [ ] ) ;
564404 expect ( console . error . mock . calls ) . toEqual ( [
565- [
566- // Reported by jsdom due to the guarded callback:
567- expect . objectContaining ( {
568- detail : expect . objectContaining ( {
569- message : 'Boom' ,
570- } ) ,
571- type : 'unhandled exception' ,
572- } ) ,
573- ] ,
574405 [
575406 // Addendum by React:
576407 expect . stringContaining (
0 commit comments