11import WebdriverIOReporter , { type SuiteStats , type TestStats } from '@wdio/reporter'
2+ import { enrichTestStats , setCurrentSpecFile } from './utils.js'
23
34export class TestReporter extends WebdriverIOReporter {
45 #report: ( data : any ) => void
6+ #currentSpecFile?: string
57
68 constructor ( options : any , report : ( data : any ) => void ) {
79 super ( options )
@@ -10,10 +12,17 @@ export class TestReporter extends WebdriverIOReporter {
1012
1113 onSuiteStart ( suiteStats : SuiteStats ) : void {
1214 super . onSuiteStart ( suiteStats )
15+ this . #currentSpecFile = suiteStats . file
16+ setCurrentSpecFile ( suiteStats . file )
1317 this . #sendUpstream( )
1418 }
1519
1620 onTestStart ( testStats : TestStats ) : void {
21+ //Enrich testStats with file + line info
22+ enrichTestStats ( testStats , this . #currentSpecFile)
23+ if ( ( testStats as any ) . file && ( testStats as any ) . line != null ) {
24+ ; ( testStats as any ) . callSource = `${ ( testStats as any ) . file } :${ ( testStats as any ) . line } `
25+ }
1726 super . onTestStart ( testStats )
1827 this . #sendUpstream( )
1928 }
@@ -25,6 +34,8 @@ export class TestReporter extends WebdriverIOReporter {
2534
2635 onSuiteEnd ( suiteStats : SuiteStats ) : void {
2736 super . onSuiteEnd ( suiteStats )
37+ this . #currentSpecFile = undefined
38+ setCurrentSpecFile ( undefined )
2839 this . #sendUpstream( )
2940 }
3041
0 commit comments