@@ -114,7 +114,7 @@ describe('console', () => {
114114 } ) ;
115115
116116 it ( 'should not append multiple stacks' , ( ) => {
117- const Child = ( ) => {
117+ const Child = ( { children } ) => {
118118 fakeConsole . warn ( 'warn\n in Child (at fake.js:123)' ) ;
119119 fakeConsole . error ( 'error' , '\n in Child (at fake.js:123)' ) ;
120120 return null ;
@@ -135,12 +135,12 @@ describe('console', () => {
135135
136136 it ( 'should append component stacks to errors and warnings logged during render' , ( ) => {
137137 const Intermediate = ( { children} ) => children ;
138- const Parent = ( ) => (
138+ const Parent = ( { children } ) => (
139139 < Intermediate >
140140 < Child />
141141 </ Intermediate >
142142 ) ;
143- const Child = ( ) => {
143+ const Child = ( { children } ) => {
144144 fakeConsole . error ( 'error' ) ;
145145 fakeConsole . log ( 'log' ) ;
146146 fakeConsole . warn ( 'warn' ) ;
@@ -149,42 +149,31 @@ describe('console', () => {
149149
150150 act ( ( ) => ReactDOM . render ( < Parent /> , document . createElement ( 'div' ) ) ) ;
151151
152- // TRICKY DevTools console override re-renders the component to intentionally trigger an error,
153- // in which case all of the mock functions will be called an additional time.
154-
155- expect ( mockError ) . toHaveBeenCalledTimes ( 2 ) ;
156- expect ( mockError . mock . calls [ 0 ] ) . toHaveLength ( 1 ) ;
157- expect ( mockError . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'error' ) ;
158- expect ( mockError . mock . calls [ 1 ] ) . toHaveLength ( 2 ) ;
159- expect ( mockError . mock . calls [ 1 ] [ 0 ] ) . toBe ( 'error' ) ;
160- expect ( normalizeCodeLocInfo ( mockError . mock . calls [ 1 ] [ 1 ] ) ) . toBe (
161- '\n in Child (at **)\n in Intermediate (at **)\n in Parent (at **)' ,
162- ) ;
163-
164- expect ( mockLog ) . toHaveBeenCalledTimes ( 2 ) ;
152+ expect ( mockLog ) . toHaveBeenCalledTimes ( 1 ) ;
165153 expect ( mockLog . mock . calls [ 0 ] ) . toHaveLength ( 1 ) ;
166154 expect ( mockLog . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'log' ) ;
167- expect ( mockLog . mock . calls [ 1 ] ) . toHaveLength ( 1 ) ;
168- expect ( mockLog . mock . calls [ 1 ] [ 0 ] ) . toBe ( 'log' ) ;
169-
170- expect ( mockWarn ) . toHaveBeenCalledTimes ( 2 ) ;
171- expect ( mockWarn . mock . calls [ 0 ] ) . toHaveLength ( 1 ) ;
155+ expect ( mockWarn ) . toHaveBeenCalledTimes ( 1 ) ;
156+ expect ( mockWarn . mock . calls [ 0 ] ) . toHaveLength ( 2 ) ;
172157 expect ( mockWarn . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'warn' ) ;
173- expect ( mockWarn . mock . calls [ 1 ] ) . toHaveLength ( 2 ) ;
174- expect ( mockWarn . mock . calls [ 1 ] [ 0 ] ) . toBe ( 'warn' ) ;
175- expect ( normalizeCodeLocInfo ( mockWarn . mock . calls [ 1 ] [ 1 ] ) ) . toEqual (
158+ expect ( normalizeCodeLocInfo ( mockWarn . mock . calls [ 0 ] [ 1 ] ) ) . toEqual (
159+ '\n in Child (at **)\n in Intermediate (at **)\n in Parent (at **)' ,
160+ ) ;
161+ expect ( mockError ) . toHaveBeenCalledTimes ( 1 ) ;
162+ expect ( mockError . mock . calls [ 0 ] ) . toHaveLength ( 2 ) ;
163+ expect ( mockError . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'error' ) ;
164+ expect ( normalizeCodeLocInfo ( mockError . mock . calls [ 0 ] [ 1 ] ) ) . toBe (
176165 '\n in Child (at **)\n in Intermediate (at **)\n in Parent (at **)' ,
177166 ) ;
178167 } ) ;
179168
180169 it ( 'should append component stacks to errors and warnings logged from effects' , ( ) => {
181170 const Intermediate = ( { children} ) => children ;
182- const Parent = ( ) => (
171+ const Parent = ( { children } ) => (
183172 < Intermediate >
184173 < Child />
185174 </ Intermediate >
186175 ) ;
187- const Child = ( ) => {
176+ const Child = ( { children } ) => {
188177 React . useLayoutEffect ( ( ) => {
189178 fakeConsole . error ( 'active error' ) ;
190179 fakeConsole . log ( 'active log' ) ;
@@ -231,7 +220,7 @@ describe('console', () => {
231220
232221 it ( 'should append component stacks to errors and warnings logged from commit hooks' , ( ) => {
233222 const Intermediate = ( { children} ) => children ;
234- const Parent = ( ) => (
223+ const Parent = ( { children } ) => (
235224 < Intermediate >
236225 < Child />
237226 </ Intermediate >
@@ -287,7 +276,7 @@ describe('console', () => {
287276
288277 it ( 'should append component stacks to errors and warnings logged from gDSFP' , ( ) => {
289278 const Intermediate = ( { children} ) => children ;
290- const Parent = ( ) => (
279+ const Parent = ( { children } ) => (
291280 < Intermediate >
292281 < Child />
293282 </ Intermediate >
@@ -325,7 +314,7 @@ describe('console', () => {
325314 } ) ;
326315
327316 it ( 'should append stacks after being uninstalled and reinstalled' , ( ) => {
328- const Child = ( ) => {
317+ const Child = ( { children } ) => {
329318 fakeConsole . warn ( 'warn' ) ;
330319 fakeConsole . error ( 'error' ) ;
331320 return null ;
@@ -344,20 +333,17 @@ describe('console', () => {
344333 patchConsole ( ) ;
345334 act ( ( ) => ReactDOM . render ( < Child /> , document . createElement ( 'div' ) ) ) ;
346335
347- // TRICKY DevTools console override re-renders the component to intentionally trigger an error,
348- // in which case all of the mock functions will be called an additional time.
349-
350- expect ( mockWarn ) . toHaveBeenCalledTimes ( 3 ) ;
351- expect ( mockWarn . mock . calls [ 2 ] ) . toHaveLength ( 2 ) ;
352- expect ( mockWarn . mock . calls [ 2 ] [ 0 ] ) . toBe ( 'warn' ) ;
353- expect ( normalizeCodeLocInfo ( mockWarn . mock . calls [ 2 ] [ 1 ] ) ) . toEqual (
336+ expect ( mockWarn ) . toHaveBeenCalledTimes ( 2 ) ;
337+ expect ( mockWarn . mock . calls [ 1 ] ) . toHaveLength ( 2 ) ;
338+ expect ( mockWarn . mock . calls [ 1 ] [ 0 ] ) . toBe ( 'warn' ) ;
339+ expect ( normalizeCodeLocInfo ( mockWarn . mock . calls [ 1 ] [ 1 ] ) ) . toEqual (
354340 '\n in Child (at **)' ,
355341 ) ;
356- expect ( mockError ) . toHaveBeenCalledTimes ( 3 ) ;
357- expect ( mockError . mock . calls [ 2 ] ) . toHaveLength ( 2 ) ;
358- expect ( mockError . mock . calls [ 2 ] [ 0 ] ) . toBe ( 'error' ) ;
359- expect ( normalizeCodeLocInfo ( mockError . mock . calls [ 2 ] [ 1 ] ) ) . toBe (
342+ expect ( mockError ) . toHaveBeenCalledTimes ( 2 ) ;
343+ expect ( mockError . mock . calls [ 1 ] ) . toHaveLength ( 2 ) ;
344+ expect ( mockError . mock . calls [ 1 ] [ 0 ] ) . toBe ( 'error' ) ;
345+ expect ( normalizeCodeLocInfo ( mockError . mock . calls [ 1 ] [ 1 ] ) ) . toBe (
360346 '\n in Child (at **)' ,
361347 ) ;
362348 } ) ;
363- } ) ;
349+ } ) ;
0 commit comments