Skip to content

Commit 28b2f11

Browse files
committed
Update Playwright configuration to conditionally use Chromatic reporter in CI and adjust GitHub Actions workflow for test results directory structure
1 parent 4884044 commit 28b2f11

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

.github/workflows/chromatic.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
# ⚠️ See your package manager's documentation for the correct command to install dependencies in a CI environment.
1717
run: npm ci
1818
- name: Create test results directory
19-
run: mkdir -p test-results
19+
run: mkdir -p test-results/chromatic-archives
2020
- name: Run Playwright tests
2121
run: |
2222
# Create Docker config directory to avoid permission warning
@@ -53,10 +53,15 @@ jobs:
5353
with:
5454
name: test-results
5555
path: ./test-results
56+
- name: Create chromatic-archives directory if missing
57+
run: |
58+
mkdir -p ./test-results/chromatic-archives
59+
# List contents to debug
60+
ls -la ./test-results/ || echo "test-results directory is empty or missing"
5661
- name: Run Chromatic
5762
uses: chromaui/action@latest
5863
with:
5964
playwright: true
6065
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
6166
env:
62-
CHROMATIC_ARCHIVE_LOCATION: ./test-results
67+
CHROMATIC_ARCHIVE_LOCATION: ./test-results/chromatic-archives

playwright.config.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ module.exports = defineConfig({
1515
/* Opt out of parallel tests on CI. */
1616
workers: process.env.CI ? 1 : undefined,
1717
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
18-
reporter: [
19-
['html'],
20-
['json', { outputFile: 'test-results/results.json' }],
21-
['junit', { outputFile: 'test-results/junit.xml' }]
22-
],
18+
reporter: process.env.CI
19+
? [
20+
['@chromatic-com/playwright', { outputDir: 'test-results/chromatic-archives' }],
21+
['json', { outputFile: 'test-results/results.json' }],
22+
['junit', { outputFile: 'test-results/junit.xml' }]
23+
]
24+
: [
25+
['html'],
26+
['json', { outputFile: 'test-results/results.json' }],
27+
['junit', { outputFile: 'test-results/junit.xml' }]
28+
],
2329
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2430
use: {
2531
/* Base URL to use in actions like `await page.goto('/')`. */

0 commit comments

Comments
 (0)