Skip to content

Commit 354bc0c

Browse files
authored
Merge pull request #231 from readium/update-automated-tests
Migrate tests to Playwright
2 parents e384936 + d203e25 commit 354bc0c

21 files changed

Lines changed: 323 additions & 1900 deletions

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Use Node.js
2525
uses: actions/setup-node@v4
2626
with:
27-
node-version: '20.x'
27+
node-version: '24.x'
2828
cache: 'npm'
2929
- run: npm ci
3030
- run: npm run build --if-present

.github/workflows/playwright.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Playwright Visual Regression
2+
3+
on:
4+
push:
5+
branches: ["develop"]
6+
pull_request:
7+
branches: ["develop"]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Use Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: "24.x"
18+
cache: npm
19+
- run: npm ci
20+
- run: npx playwright install --with-deps chromium
21+
- run: npm test
22+
- uses: actions/upload-artifact@v4
23+
if: failure()
24+
with:
25+
name: playwright-report
26+
path: tests/playwright-report/
27+
retention-days: 14
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Update Playwright Snapshots
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
update:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
ref: ${{ github.ref }}
15+
fetch-depth: 0
16+
- name: Use Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: "24.x"
20+
cache: npm
21+
- run: npm ci
22+
- run: npx playwright install --with-deps chromium
23+
- run: npm run build && npx playwright test --update-snapshots
24+
- uses: stefanzweifel/git-auto-commit-action@v5
25+
with:
26+
commit_message: "chore: update playwright snapshots"
27+
file_pattern: "tests/snapshots/*.png"

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
node_modules/
22
*.css.map
3-
tests/backstop_data/
3+
tests/backstop_data/
4+
tests/snapshots/local/
5+
tests/test-results/
6+
tests/playwright-report/
7+
blob-report/
8+
playwright/.cache/

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20
1+
v24

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ Building and testing are relying on npm packages and scripts. To initialize your
5656
npm install
5757
```
5858

59-
In case you’re encountering an error with Puppeteer, make sure you’re using at least Node v.20.11.1 – it might work with an earlier version but only the latest LTS as of March 21, 2024 has been tested.
60-
61-
Then create reference bitmaps for visual regression testing:
59+
Then install the Playwright browser binary and generate reference screenshots for visual regression testing:
6260

6361
```
64-
npm run test:ref
62+
npx playwright install chromium
63+
npm run test:update
6564
```
6665

6766
### Build
@@ -78,10 +77,10 @@ To test the updated styles and catch visual regression bugs:
7877
npm run test
7978
```
8079

81-
To update reference bitmaps after a bugfix:
80+
To update reference screenshots after an intentional change:
8281

8382
```
84-
npm run test:approve
83+
npm run test:update
8584
```
8685

8786
## Docs

0 commit comments

Comments
 (0)