@@ -2,6 +2,8 @@ import React from 'react';
22import sinon from 'sinon-sandbox' ;
33import { expect } from 'chai' ;
44
5+ import path from 'path' ;
6+
57import { is } from '../../_helpers/version' ;
68import {
79 describeIf ,
@@ -251,23 +253,32 @@ export default function describeCDC({
251253 if ( is ( '>= 17' ) ) {
252254 expect ( info ) . to . have . property ( 'componentStack' ) ;
253255 expect ( info . componentStack ) . to . match ( / a t T h r o w e r ( .+ ) \n / ) ;
254- }
255- // else {
256- var FILE_PATH = __filename . replace ( / ^ .* ?( \/ b u i l d ) / , '$1' ) ;
257- var inStr = is ( '>= 17' ) ? 'at' : 'in' ;
258- info . componentStack = info . componentStack . replace ( / ^ .* ?( \/ b u i l d ) / , '$1' ) ;
259- info . componentStack = info . componentStack . replace ( / a t / g, inStr ) ;
256+ }
257+ const FILE_PATH = __filename ;
258+ const MOUNT_WRAPPER_PATH = path . join (
259+ FILE_PATH ,
260+ '../../../../../enzyme-adapter-utils/build/createMountWrapper.js' ,
261+ ) ;
262+ info . componentStack = info . componentStack
263+ . replace ( / ^ .* ?( \/ b u i l d ) / , '$1' )
264+ . replace ( / ( [ ^ ( ] + \/ [ ^ : ] + ) : \d + : \d + / gm, '$1:$LINE:$COL' ) ;
260265 expect ( info ) . to . deep . equal ( {
261- componentStack : `
262- ${ inStr } Thrower (${ FILE_PATH } )
263- ${ inStr } span (${ FILE_PATH } )${ hasFragments ? '' : `
264- in main (${ FILE_PATH } )` }
265- ${ inStr } div (${ FILE_PATH } )
266- ${ inStr } ErrorBoundary (created by ErrorSFC)
267- ${ inStr } ErrorSFC (created by WrapperComponent)
268- ${ inStr } WrapperComponent` ,
266+ componentStack : is ( '>= 17' )
267+ ? `
268+ at Thrower (${ __filename } :$LINE:$COL)
269+ at span
270+ at div
271+ at ErrorBoundary (${ FILE_PATH } :$LINE:$COL)
272+ at ErrorSFC
273+ at WrapperComponent (${ MOUNT_WRAPPER_PATH } :$LINE:$COL)`
274+ : `
275+ in Thrower (${ __filename } :$LINE:$COL
276+ in span (created by ErrorBoundary)
277+ in div (created by ErrorBoundary)
278+ in ErrorBoundary (created by ErrorSFC)
279+ in ErrorSFC (created by WrapperComponent)
280+ in WrapperComponent:$LINE:$COL` ,
269281 } ) ;
270- // }
271282 } ) ;
272283 } ) ;
273284 } ) ;
0 commit comments