Skip to content

Commit 74eda4b

Browse files
committed
use test ids and trace file path
1 parent b15d33a commit 74eda4b

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

.github/workflows/playwright.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,20 @@ jobs:
3939
if: ${{ !cancelled() }}
4040
with:
4141
filepath: ./playwright-errors/errors.md
42-
- uses: initdc/upload-artifact@baac12d9f85834b2f8baa26a08ff97c27cc82cd9
42+
- name: Get trace files
43+
id: get-trace-files
44+
if: ${{ !cancelled() }}
45+
run: |
46+
IDS=$(cat ./playwright-errors/testIds.json)
47+
TRACES=$(cat ./playwright-errors/traceFiles.json)
48+
echo "testIds=$IDS" >> $GITHUB_OUTPUT
49+
echo "traceFiles=$TRACES" >> $GITHUB_OUTPUT
50+
- uses: BToersche/upload-artifact@5442a4e8a3867a1c14be1ee3a04c4f47b261d632
4351
id: upload-traces
4452
if: ${{ !cancelled() }}
4553
with:
46-
artifact-per-file: true
47-
artifact-name-rule: ${name}${ext}
48-
path: |
49-
test-results/*/trace.zip
54+
name: '${{ steps.get-trace-files.outputs.testIds }}'
55+
path: '${{ steps.get-trace-files.outputs.traceFiles }}'
5056
retention-days: 1
5157
- uses: actions/upload-artifact@v4
5258
if: ${{ !cancelled() }}

e2e/config/reporter.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ const ansiRegex = new RegExp( '([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]
1111
class 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
}
94110
export default MyReporter

0 commit comments

Comments
 (0)