Skip to content

Commit f5736ce

Browse files
committed
chore: migrate to chromatic for CI testing
Signed-off-by: Ulises Gascon <ulisesgascongonzalez@gmail.com>
1 parent 769e064 commit f5736ce

10 files changed

Lines changed: 31 additions & 14 deletions

File tree

.github/workflows/playwright.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,25 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5
20+
with:
21+
fetch-depth: 0
2022
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 #v5
2123
with:
2224
node-version: 22
2325

2426
- name: Install dependencies
2527
run: |
2628
yarn install --frozen-lockfile
27-
yarn add -D @playwright/test@latest
28-
npx playwright install --with-deps
29+
yarn add -D @playwright/test chromatic @chromatic-com/playwright
30+
yarn playwright install --with-deps
2931
3032
- name: Run Playwright tests
31-
run: npx playwright test
33+
run: yarn playwright test
34+
env:
35+
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
36+
37+
- name: Run test and Upload the generated Chromatic archives
38+
run: yarn chromatic --playwright -t="$CHROMATIC_PROJECT_TOKEN"
39+
env:
40+
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
41+
ENABLE_SNAPSHOTS: 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: 6 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,9 @@ 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.ENABLE_SNAPSHOTS) {
62+
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(
63+
'home.png'
64+
)
65+
}
6266
})
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.ENABLE_SNAPSHOTS) {
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.ENABLE_SNAPSHOTS) {
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)