Skip to content

Commit 4cda181

Browse files
committed
chore: migrate to chromatic for CI testing
Signed-off-by: Ulises Gascon <[email protected]>
1 parent 769e064 commit 4cda181

File tree

10 files changed

+29
-16
lines changed

10 files changed

+29
-16
lines changed

.github/workflows/playwright.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,31 @@ jobs:
99
test-docs:
1010
name: E2E Testing
1111
runs-on: ubuntu-latest
12-
env:
13-
CI: true
1412
defaults:
1513
run:
1614
working-directory: scorecards-site
1715

1816
steps:
1917
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5
18+
with:
19+
fetch-depth: 0
2020
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 #v5
2121
with:
2222
node-version: 22
2323

2424
- name: Install dependencies
2525
run: |
2626
yarn install --frozen-lockfile
27-
yarn add -D @playwright/test@latest
28-
npx playwright install --with-deps
27+
yarn add -D @playwright/test chromatic @chromatic-com/playwright
28+
yarn playwright install --with-deps
2929
3030
- name: Run Playwright tests
31-
run: npx playwright test
31+
run: yarn playwright test
32+
env:
33+
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
34+
35+
- name: Run test and Upload the generated Chromatic archives
36+
run: yarn chromatic --playwright -t="$CHROMATIC_PROJECT_TOKEN"
37+
env:
38+
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
39+
CI: true

scorecards-site/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ To run tests locally, you must install Playwright manually and avoid committing
3737
### Temporary local installation
3838

3939
```sh
40-
yarn add -D @playwright/test@latest
41-
yarn playwright install --with-deps
40+
yarn add -D @playwright/test chromatic @chromatic-com/playwright
4241
```
4342

4443
These changes are temporary and should not be committed.

scorecards-site/tests-e2e/home.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
import path from 'path'
33
import fs from 'fs'
4-
import { test, expect } from '@playwright/test'
4+
import { test, expect } from '@chromatic-com/playwright'
55

66
const mockRepoDataPath = path.resolve(
77
__dirname,
@@ -58,5 +58,7 @@ test('Home Page', async ({ page }) => {
5858
})
5959

6060
// Prevent Visual Regressions
61-
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot('home.png')
61+
if (process.env.CI) {
62+
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot('home.png')
63+
}
6264
})
Binary file not shown.
Binary file not shown.

scorecards-site/tests-e2e/viewer.spec.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
import path from 'path'
33
import fs from 'fs'
4-
import { test, expect } from '@playwright/test'
4+
import { test, expect } from '@chromatic-com/playwright'
55

66
const mockScorecardDataPath = path.resolve(
77
__dirname,
@@ -14,9 +14,11 @@ test('viewer welcome', async ({ page }) => {
1414
await page.goto('http://localhost:3000/viewer')
1515

1616
// Prevent Visual Regressions
17-
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(
18-
'viewer-welcome.png'
19-
)
17+
if (process.env.CI) {
18+
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(
19+
'viewer-welcome.png'
20+
)
21+
}
2022

2123
// Find input field and type the repo URL.
2224
const input = page.locator('input[placeholder="github.com/ossf/scorecard"]')
@@ -57,7 +59,9 @@ test('viewer details', async ({ page }) => {
5759
await page.waitForTimeout(5 * 1000)
5860

5961
// Prevent Visual Regressions
60-
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(
61-
'viewer-details.png'
62-
)
62+
if (process.env.CI) {
63+
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(
64+
'viewer-details.png'
65+
)
66+
}
6367
})
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)