@@ -11,11 +11,15 @@ const ansiRegex = new RegExp( '([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]
1111class MyReporter implements Reporter {
1212 outputFolder : string ;
1313 testResults : Array < string > ;
14+ testIds : Array < string > ;
15+ traceFiles : Array < string > ;
1416
1517 constructor ( ) {
1618 this . outputFolder = 'playwright-errors'
1719 this . cleanupFolder ( )
1820 this . testResults = [ ]
21+ this . testIds = [ ]
22+ this . traceFiles = [ ]
1923 }
2024
2125 stripAnsiEscapes ( str : string ) : string {
@@ -67,6 +71,8 @@ class MyReporter implements Reporter {
6771 }
6872
6973 this . testResults . push ( testResult )
74+ this . testIds . push ( test . id )
75+ this . traceFiles . push ( result . attachments . find ( attachment => attachment . name === 'trace' ) . path )
7076 }
7177 }
7278
@@ -80,15 +86,25 @@ class MyReporter implements Reporter {
8086 // Write the collected results to a JSON file
8187 const reportPath = path . join ( folderPath , 'errors.md' )
8288 let reportContent = ''
89+
90+ const testIdsPath = path . join ( folderPath , 'testIds.json' )
91+ let testIdsContent = ''
92+
93+ const traceFilesPath = path . join ( folderPath , 'traceFiles.json' )
94+ let traceFilesContent = ''
8395 if ( this . testResults . length ) {
8496 reportContent += `## Failed Tests
8597
8698${ this . testResults . join ( '' ) } `
8799
88100 reportContent = this . stripAnsiEscapes ( reportContent )
101+ testIdsContent = JSON . stringify ( this . testIds , null , 2 )
102+ traceFilesContent = JSON . stringify ( this . traceFiles , null , 2 )
89103 }
90104
91105 fs . writeFileSync ( reportPath , reportContent )
106+ fs . writeFileSync ( testIdsPath , testIdsContent )
107+ fs . writeFileSync ( traceFilesPath , traceFilesContent )
92108 }
93109}
94110export default MyReporter
0 commit comments