@@ -149,11 +149,11 @@ function createSuiteCollector(name: string, factory: SuiteFactory = () => { }, m
149149
150150 if ( runner . config . includeTaskLocation ) {
151151 const limit = Error . stackTraceLimit
152- // custom can be called from any place, let's assume the limit is 10 stacks
153- Error . stackTraceLimit = 10
152+ // custom can be called from any place, let's assume the limit is 15 stacks
153+ Error . stackTraceLimit = 15
154154 const error = new Error ( 'stacktrace' ) . stack !
155155 Error . stackTraceLimit = limit
156- const stack = findStackTrace ( error , task . each ?? false )
156+ const stack = findTestFileStackTrace ( error , task . each ?? false )
157157 if ( stack )
158158 task . location = stack
159159 }
@@ -219,18 +219,12 @@ function createSuiteCollector(name: string, factory: SuiteFactory = () => { }, m
219219
220220 if ( runner && includeLocation && runner . config . includeTaskLocation ) {
221221 const limit = Error . stackTraceLimit
222- Error . stackTraceLimit = 5
222+ Error . stackTraceLimit = 15
223223 const error = new Error ( 'stacktrace' ) . stack !
224224 Error . stackTraceLimit = limit
225- const stack = parseSingleStack ( error . split ( '\n' ) [ 5 ] )
226- if ( stack ) {
227- suite . location = {
228- line : stack . line ,
229- // because source map is boundary based, this line leads to ")" in test.each()[(]),
230- // but it should be the next opening bracket - here we assume it's on the same line
231- column : each ? stack . column + 1 : stack . column ,
232- }
233- }
225+ const stack = findTestFileStackTrace ( error , suite . each ?? false )
226+ if ( stack )
227+ suite . location = stack
234228 }
235229
236230 setHooks ( suite , createSuiteHooks ( ) )
@@ -432,10 +426,9 @@ function formatTemplateString(cases: any[], args: any[]): any[] {
432426 return res
433427}
434428
435- function findStackTrace ( error : string , each : boolean ) {
429+ function findTestFileStackTrace ( error : string , each : boolean ) {
436430 // first line is the error message
437- // and the first 3 stacks are always from the collector
438- const lines = error . split ( '\n' ) . slice ( 4 )
431+ const lines = error . split ( '\n' ) . slice ( 1 )
439432 for ( const line of lines ) {
440433 const stack = parseSingleStack ( line )
441434 if ( stack && stack . file === getTestFilepath ( ) ) {
0 commit comments