Skip to content

Commit 7779f57

Browse files
committed
feat(#1369486): add playwright screenshots and video on test failures
1 parent ad28bc8 commit 7779f57

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

.github/workflows/tests.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ jobs:
3535
if: github.event.pull_request.draft == false
3636
name: Tests
3737
runs-on: ubuntu-24.04
38-
38+
3939
env:
4040
ref: ${{ inputs.use_default_github_ref == false && inputs.version || '' }}
4141
composer_version: ${{ inputs.version == 'main' && 'dev-main' || (contains(inputs.version, 'x') && format('{0}-dev', inputs.version) || inputs.version) }}
4242
docker_compose_cmd: docker compose -f compose.yml -f compose.ci.yml ${{ inputs.search_engine != 'opensearch' && format('-f compose.{0}.yml', inputs.search_engine) || '' }}
43-
43+
4444
steps:
4545
- name: Disk cleanup
4646
shell: bash
@@ -163,9 +163,17 @@ jobs:
163163
run: ${{env.docker_compose_cmd}} exec -T pwa yarn test:ci
164164

165165
- name: e2e
166+
id: e2e
166167
continue-on-error: true
167168
run: ${{env.docker_compose_cmd}} exec -T e2e yarn test:ci
168169

170+
- uses: actions/upload-artifact@v4
171+
if: ${{ always() }}
172+
with:
173+
name: playwright-report
174+
path: front/e2e/playwright-report
175+
retention-days: 30
176+
169177
- name: Frontend Coverage Report
170178
uses: 5monkeys/cobertura-action@v12
171179
if: ${{ github.event_name == 'pull_request' }}

compose.ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
services:
2-
2+
33
certbot:
44
environment:
55
- SELF_SIGNED=true
6-
6+
77
php:
88
build:
99
target: gally_php_ci
@@ -37,5 +37,7 @@ services:
3737
extends:
3838
file: ./compose.e2e.yml
3939
service: e2e
40+
volumes:
41+
- ./front/e2e/playwright-report:/usr/src/app/playwright-report:rw,cached,z
4042
environment:
4143
- CI=true

front/e2e/playwright.config.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,46 @@
11
import { defineConfig, devices } from '@playwright/test'
22

3+
const reporters: Array<[string, Record<string, unknown>]> = [
4+
['list', {printSteps: true}],
5+
]
6+
7+
if (process.env.CI) {
8+
reporters.push(['html', {outputFolder: 'playwright-report', open: 'never'}])
9+
}
10+
311
export default defineConfig({
412
testDir: './src/tests',
513
fullyParallel: false,
614
forbidOnly: !!process.env.CI,
715
retries: process.env.CI ? 0 : 0, // Experimental settings, update it if necessary for the CI
816
workers: process.env.CI ? 1 : 1, // We put 1 worker even for dev mode to save computer resources
9-
reporter: [['list', {printSteps: true}]],
17+
reporter: reporters,
1018
timeout: process.env.CI ? 180000 : 120000, // 3min in CI per test, 2min in local
1119
use: {
1220
baseURL: process.env.SERVER_BASE_URL || 'https://gally.local',
13-
trace: 'on',
21+
// In CI trace is kept only on failure to avoid huge artifacts
22+
trace: process.env.CI ? 'retain-on-failure' : 'on',
1423
headless: true,
1524
ignoreHTTPSErrors: true,
1625
permissions: ['clipboard-read', 'clipboard-write'],
26+
// Capture screenshot and video on test failure in CI env for easier debugging.
27+
screenshot: process.env.CI ? 'only-on-failure' : 'off',
28+
// Record videos at lower size than the viewport to save space
29+
video: process.env.CI
30+
? { mode: 'retain-on-failure', size: { width: 960, height: 540 } }
31+
: 'off',
1732
},
1833
expect: {
1934
timeout: process.env.CI ? 30000 : 20000, // 30s in CI per expect, 20s in local,
2035
},
2136
projects: [
2237
{
2338
name: 'chromium',
24-
use: {...devices['Desktop Chrome']},
39+
use: {
40+
...devices['Desktop Chrome'],
41+
// Increase viewport resolution for easier visual debugging
42+
viewport: { width: 1920, height: 1080 },
43+
},
2544
},
2645
],
2746
})

0 commit comments

Comments
 (0)