@@ -149,11 +149,11 @@ function createSuiteCollector(name: string, factory: SuiteFactory = () => { }, m
149
149
150
150
if ( runner . config . includeTaskLocation ) {
151
151
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
154
154
const error = new Error ( 'stacktrace' ) . stack !
155
155
Error . stackTraceLimit = limit
156
- const stack = findStackTrace ( error , task . each ?? false )
156
+ const stack = findTestFileStackTrace ( error , task . each ?? false )
157
157
if ( stack )
158
158
task . location = stack
159
159
}
@@ -219,18 +219,12 @@ function createSuiteCollector(name: string, factory: SuiteFactory = () => { }, m
219
219
220
220
if ( runner && includeLocation && runner . config . includeTaskLocation ) {
221
221
const limit = Error . stackTraceLimit
222
- Error . stackTraceLimit = 5
222
+ Error . stackTraceLimit = 15
223
223
const error = new Error ( 'stacktrace' ) . stack !
224
224
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
234
228
}
235
229
236
230
setHooks ( suite , createSuiteHooks ( ) )
@@ -432,10 +426,9 @@ function formatTemplateString(cases: any[], args: any[]): any[] {
432
426
return res
433
427
}
434
428
435
- function findStackTrace ( error : string , each : boolean ) {
429
+ function findTestFileStackTrace ( error : string , each : boolean ) {
436
430
// 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 )
439
432
for ( const line of lines ) {
440
433
const stack = parseSingleStack ( line )
441
434
if ( stack && stack . file === getTestFilepath ( ) ) {
0 commit comments