Skip to content

Commit a3cb37d

Browse files
committed
update comment content
1 parent abf48b9 commit a3cb37d

File tree

4 files changed

+49
-79
lines changed

4 files changed

+49
-79
lines changed

.github/scripts/unzip_traces.sh

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/workflows/playwright.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ jobs:
3434
WP_PASSWORD: password
3535
STACKABLE_SLUG: Stackable/plugin
3636
run: npm run test
37-
- name: Run script to unzip and upload traces
38-
if: ${{ !cancelled() }}
37+
- name: Get failed tests
38+
id: get-failed-tests
3939
run: |
40-
chmod +x ./.github/scripts/unzip_traces.sh
41-
./.github/scripts/unzip_traces.sh
40+
CONTENT=$(cat ./playwright-errors/errors.md)
41+
echo "::set-output name=content::$CONTENT"
4242
- uses: actions/upload-artifact@v4
4343
if: ${{ !cancelled() }}
4444
id: artifact-upload-step
@@ -62,6 +62,7 @@ jobs:
6262
comment-id: ${{ steps.fc.outputs.comment-id }}
6363
issue-number: ${{ github.event.pull_request.number }}
6464
body: |
65+
${{ steps.get-failed-tests.outputs.content }}
6566
## Playwright Report Artifact
6667
| file | commit |
6768
| ---- | ------ |

e2e/config/reporter.ts

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ import path from 'path'
88

99
class MyReporter implements Reporter {
1010
outputFolder: string;
11-
testResults: Array<{title: string, id: string, trace: any}>;
11+
testResults: Array<string>;
1212

1313
constructor() {
14-
this.outputFolder = 'playwright-traces'
14+
this.outputFolder = 'playwright-errors'
1515
this.cleanupFolder()
1616
this.testResults = []
1717
}
18+
19+
removeColorCodes( input : string ) {
20+
return input.replace( /\[[0-9;]*m/g, '' )
21+
}
22+
1823
cleanupFolder() {
1924
const folderPath = path.resolve( this.outputFolder )
2025

@@ -35,14 +40,31 @@ class MyReporter implements Reporter {
3540
}
3641

3742
onTestEnd( test: TestCase, result: TestResult ) {
38-
if ( result.attachments.length !== 0 ) {
39-
console.log( 'title:', test.title )
40-
console.log( 'attachments', result.attachments )
41-
this.testResults.push( {
42-
id: test.id,
43-
title: test.title,
44-
trace: result.attachments.find( attachment => attachment.name === 'trace' ).path,
45-
} )
43+
if ( result.status !== test.expectedStatus ) {
44+
let testResult = `### ${ test.title }
45+
`
46+
if ( result.errors.length >= 1 ) {
47+
testResult += `\`\`\`
48+
`
49+
result.errors.forEach( error => {
50+
if ( error.message ) {
51+
testResult += `${ this.removeColorCodes( error.message ) }
52+
53+
`
54+
}
55+
56+
if ( error.snippet ) {
57+
testResult += `${ this.removeColorCodes( error.snippet ) }
58+
59+
`
60+
}
61+
} )
62+
testResult += `\`\`\`
63+
64+
`
65+
}
66+
67+
this.testResults.push( testResult )
4668
}
4769
}
4870

@@ -54,8 +76,15 @@ class MyReporter implements Reporter {
5476
}
5577

5678
// Write the collected results to a JSON file
57-
const reportPath = path.join( folderPath, 'test-traces.json' )
58-
fs.writeFileSync( reportPath, JSON.stringify( this.testResults, null, 2 ) )
79+
const reportPath = path.join( folderPath, 'errors.md' )
80+
let reportContent = ''
81+
if ( this.testResults.length ) {
82+
reportContent += `## Failed Tests
83+
84+
${ this.testResults.join( '' ) }`
85+
}
86+
87+
fs.writeFileSync( reportPath, reportContent )
5988
}
6089
}
6190
export default MyReporter

e2e/playwright.config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ export default defineConfig( {
2323
/* Fail the build on CI if you accidentally left test.only in the source code. */
2424
// forbidOnly: !! process.env.CI,
2525
/* Retry on CI only */
26-
// retries: process.env.CI ? 2 : 0,
27-
retries: 0,
26+
retries: process.env.CI ? 1 : 0,
2827
// Locally, we could take advantage of parallelism due to multicore systems.
2928
// However, in the CI, we typically can use only one worker at a time.
3029
// It's more straightforward to align how we run tests in both systems.
@@ -33,8 +32,8 @@ export default defineConfig( {
3332
workers: 1,
3433
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
3534
reporter: process.env.CI
36-
? [ [ 'list' ], [ 'github', { useDetails: true, showError: true } ], [ 'html', { outputFolder: '../playwright-report' } ], [ './config/reporter.ts' ] ]
37-
: [ [ 'list' ], [ 'html', { outputFolder: '../playwright-report' } ] ],
35+
? [ [ 'list' ], [ 'html', { outputFolder: '../playwright-report', open: 'never' } ], [ './config/reporter.ts' ] ]
36+
: [ [ 'list' ], [ 'html', { outputFolder: '../playwright-report', open: 'never' } ] ],
3837
reportSlowTests: null,
3938
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
4039
use: {

0 commit comments

Comments
 (0)