@@ -26,7 +26,6 @@ import type { Annotation, FullConfigInternal, FullProjectInternal } from '../com
26
26
import type { FullConfig , Location } from '../../types/testReporter' ;
27
27
import { debugTest , filteredStackTrace , formatLocation , getContainedPath , normalizeAndSaveAttachment , trimLongString , windowsFilesystemFriendlyLength } from '../util' ;
28
28
import { TestTracing } from './testTracing' ;
29
- import type { StackFrame } from '@protocol/channels' ;
30
29
import { testInfoError } from './util' ;
31
30
32
31
export interface TestStepInternal {
@@ -35,8 +34,8 @@ export interface TestStepInternal {
35
34
stepId : string ;
36
35
title : string ;
37
36
category : string ;
38
- location ? : Location ;
39
- boxedStack ?: StackFrame [ ] ;
37
+ stack : Location [ ] ;
38
+ boxedStack ?: Location [ ] ;
40
39
steps : TestStepInternal [ ] ;
41
40
endWallTime ?: number ;
42
41
apiName ?: string ;
@@ -244,7 +243,7 @@ export class TestInfoImpl implements TestInfo {
244
243
?? this . _findLastStageStep ( this . _steps ) ; // If no parent step on stack, assume the current stage as parent.
245
244
}
246
245
247
- _addStep ( data : Omit < TestStepInternal , 'complete' | 'stepId' | 'steps' | 'attachmentIndices' > , parentStep ?: TestStepInternal ) : TestStepInternal {
246
+ _addStep ( data : Omit < TestStepInternal , 'complete' | 'stepId' | 'steps' | 'attachmentIndices' | 'stack' > , parentStep ?: TestStepInternal , stackOverride ?: Location [ ] ) : TestStepInternal {
248
247
const stepId = `${ data . category } @${ ++ this . _lastStepId } ` ;
249
248
250
249
if ( data . isStage ) {
@@ -255,18 +254,20 @@ export class TestInfoImpl implements TestInfo {
255
254
parentStep = this . _parentStep ( ) ;
256
255
}
257
256
258
- const filteredStack = filteredStackTrace ( captureRawStack ( ) ) ;
257
+ const filteredStack = stackOverride ? stackOverride : filteredStackTrace ( captureRawStack ( ) ) ;
259
258
data . boxedStack = parentStep ?. boxedStack ;
259
+ let stack = filteredStack ;
260
260
if ( ! data . boxedStack && data . box ) {
261
261
data . boxedStack = filteredStack . slice ( 1 ) ;
262
- data . location = data . location || data . boxedStack [ 0 ] ;
262
+ // Only steps with box: true get boxed stack. Inner steps have original stack for better traceability.
263
+ stack = data . boxedStack ;
263
264
}
264
- data . location = data . location || filteredStack [ 0 ] ;
265
265
266
266
const attachmentIndices : number [ ] = [ ] ;
267
267
const step : TestStepInternal = {
268
268
stepId,
269
269
...data ,
270
+ stack,
270
271
steps : [ ] ,
271
272
attachmentIndices,
272
273
complete : result => {
@@ -319,10 +320,10 @@ export class TestInfoImpl implements TestInfo {
319
320
title : data . title ,
320
321
category : data . category ,
321
322
wallTime : Date . now ( ) ,
322
- location : data . location ,
323
+ stack ,
323
324
} ;
324
325
this . _onStepBegin ( payload ) ;
325
- this . _tracing . appendBeforeActionForStep ( stepId , parentStep ?. stepId , data . category , data . apiName || data . title , data . params , data . location ? [ data . location ] : [ ] ) ;
326
+ this . _tracing . appendBeforeActionForStep ( stepId , parentStep ?. stepId , data . category , data . apiName || data . title , data . params , stack ) ;
326
327
return step ;
327
328
}
328
329
@@ -351,7 +352,7 @@ export class TestInfoImpl implements TestInfo {
351
352
const location = stage . runnable ?. location ? ` at "${ formatLocation ( stage . runnable . location ) } "` : `` ;
352
353
debugTest ( `started stage "${ stage . title } "${ location } ` ) ;
353
354
}
354
- stage . step = stage . stepInfo ? this . _addStep ( { ... stage . stepInfo , title : stage . title , isStage : true } ) : undefined ;
355
+ stage . step = stage . stepInfo ? this . _addStep ( { category : stage . stepInfo . category , title : stage . title , isStage : true } , undefined , stage . stepInfo . location ? [ stage . stepInfo . location ] : undefined ) : undefined ;
355
356
356
357
try {
357
358
await this . _timeoutManager . withRunnable ( stage . runnable , async ( ) => {
0 commit comments