Skip to content

Commit f9c52f4

Browse files
committed
test(storybook): improve reporting on failed tests
1 parent ddea7f1 commit f9c52f4

File tree

5 files changed

+115
-25
lines changed

5 files changed

+115
-25
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ jobs:
5555
with:
5656
name: playwright-traces
5757
path: packages/storybook/test-results
58+
- name: Upload Playwright Report
59+
uses: actions/upload-artifact@v4
60+
if: ${{ failure() && steps.test_projects.conclusion == 'failure' }}
61+
with:
62+
name: playwright-report
63+
path: packages/storybook/playwright-report
64+
retention-days: 30
5865
- name: Upload build artifacts for canary release
5966
uses: ./.github/workflows/artifacts-upload
6067
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Thumbs.db
2424
UserInterfaceState.xcuserstate
2525

2626
storybook-static/
27+
playwright-report/
2728
test-results/
2829

2930
.yalc

packages/storybook/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"remark-gfm": "^3.0.1"
5656
},
5757
"devDependencies": {
58+
"@estruyf/github-actions-reporter": "^1.11.0",
5859
"@playwright/test": "^1.56.0",
5960
"@pxtrn/storybook-addon-docs-stencil": "^6.4.0",
6061
"@storybook/addon-docs": "^7.6.12",

packages/storybook/playwright.config.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
11
import { defineConfig, devices } from '@playwright/test';
2-
import { fileURLToPath } from 'url';
2+
import type { GitHubActionOptions } from '@estruyf/github-actions-reporter';
33

4-
// @ts-expect-error we probably need a custom tsconfig for the playwright environment
5-
const __filename = fileURLToPath(import.meta.url);
6-
const STORYBOOK_URL = 'http://localhost:6007';
7-
// For CI, you may want to set BASE_URL to the deployed application.
8-
const baseURL = process.env['BASE_URL'] || STORYBOOK_URL; // storybook URL
9-
/**
10-
* Read environment variables from file.
11-
* https://github.com/motdotla/dotenv
12-
*/
13-
// require('dotenv').config();
144
/**
155
* See https://playwright.dev/docs/test-configuration.
166
*/
177
export default defineConfig({
188
testDir: 'src',
9+
10+
fullyParallel: true,
11+
12+
/* Fail the build on CI if you accidentally left test.only in the source code. */
13+
forbidOnly: !!process.env.CI,
14+
15+
/* Retry on CI only */
16+
retries: process.env.CI ? 2 : 0,
17+
18+
reporter: process.env.CI
19+
? [
20+
['html', { open: 'never' }],
21+
[
22+
'@estruyf/github-actions-reporter',
23+
<GitHubActionOptions>{
24+
useDetails: true,
25+
includeResults: ['fail', 'flaky', 'skipped'],
26+
},
27+
],
28+
]
29+
: [['list'], ['html', { open: 'never' }]],
30+
1931
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2032
use: {
21-
baseURL,
22-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
23-
trace: 'on-all-retries',
33+
trace: 'retain-on-failure',
34+
video: process.env.ci ? 'off' : 'retain-on-failure',
2435
},
2536
expect: {
2637
timeout: process.env.CI ? 30000 : 10000,
2738
},
28-
reporter: process.env.CI ? 'dot' : 'list',
2939
/* Run your local dev server before starting the tests */
3040
webServer: {
3141
command: 'pnpm run start:prod',
32-
url: STORYBOOK_URL,
42+
port: 6007,
3343
reuseExistingServer: !process.env.CI,
3444
timeout: 120000,
3545
},

pnpm-lock.yaml

Lines changed: 80 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)