Skip to content

Commit

Permalink
use test ids and trace file path
Browse files Browse the repository at this point in the history
  • Loading branch information
mxkae committed Feb 7, 2025
1 parent b15d33a commit 74eda4b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ jobs:
if: ${{ !cancelled() }}
with:
filepath: ./playwright-errors/errors.md
- uses: initdc/upload-artifact@baac12d9f85834b2f8baa26a08ff97c27cc82cd9
- name: Get trace files
id: get-trace-files
if: ${{ !cancelled() }}
run: |
IDS=$(cat ./playwright-errors/testIds.json)
TRACES=$(cat ./playwright-errors/traceFiles.json)
echo "testIds=$IDS" >> $GITHUB_OUTPUT
echo "traceFiles=$TRACES" >> $GITHUB_OUTPUT
- uses: BToersche/upload-artifact@5442a4e8a3867a1c14be1ee3a04c4f47b261d632
id: upload-traces
if: ${{ !cancelled() }}
with:
artifact-per-file: true
artifact-name-rule: ${name}${ext}
path: |
test-results/*/trace.zip
name: '${{ steps.get-trace-files.outputs.testIds }}'
path: '${{ steps.get-trace-files.outputs.traceFiles }}'
retention-days: 1
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
Expand Down
16 changes: 16 additions & 0 deletions e2e/config/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ const ansiRegex = new RegExp( '([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]
class MyReporter implements Reporter {
outputFolder: string;
testResults: Array<string>;
testIds: Array<string>;
traceFiles: Array<string>;

constructor() {
this.outputFolder = 'playwright-errors'
this.cleanupFolder()
this.testResults = []
this.testIds = []
this.traceFiles = []
}

stripAnsiEscapes( str: string ): string {
Expand Down Expand Up @@ -67,6 +71,8 @@ class MyReporter implements Reporter {
}

this.testResults.push( testResult )
this.testIds.push( test.id )
this.traceFiles.push( result.attachments.find( attachment => attachment.name === 'trace' ).path )
}
}

Expand All @@ -80,15 +86,25 @@ class MyReporter implements Reporter {
// Write the collected results to a JSON file
const reportPath = path.join( folderPath, 'errors.md' )
let reportContent = ''

const testIdsPath = path.join( folderPath, 'testIds.json' )
let testIdsContent = ''

const traceFilesPath = path.join( folderPath, 'traceFiles.json' )
let traceFilesContent = ''
if ( this.testResults.length ) {
reportContent += `## Failed Tests
${ this.testResults.join( '' ) }`

reportContent = this.stripAnsiEscapes( reportContent )
testIdsContent = JSON.stringify( this.testIds, null, 2 )
traceFilesContent = JSON.stringify( this.traceFiles, null, 2 )
}

fs.writeFileSync( reportPath, reportContent )
fs.writeFileSync( testIdsPath, testIdsContent )
fs.writeFileSync( traceFilesPath, traceFilesContent )
}
}
export default MyReporter

0 comments on commit 74eda4b

Please sign in to comment.