Skip to content

Commit a555f13

Browse files
authored
test: run tests against firefox and webdriverio too (#2)
1 parent 8ade7ea commit a555f13

File tree

7 files changed

+1472
-16
lines changed

7 files changed

+1472
-16
lines changed

.github/actions/setup-and-cache/action.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,47 @@ runs:
1010
using: "composite"
1111
steps:
1212
- name: Install pnpm
13-
uses: pnpm/action-setup@v2
13+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
1414

15-
- uses: actions/setup-node@v4
15+
- name: Set node version to ${{ inputs.node-version }}
16+
uses: actions/setup-node@v4
1617
with:
1718
node-version: ${{ inputs.node-version }}
1819
registry-url: "https://registry.npmjs.org"
1920

21+
- name: Resolve package versions
22+
id: resolve-package-versions
23+
shell: bash
24+
run: >
25+
echo "$(
26+
node -e "
27+
const fs = require('fs');
28+
const lockfile = fs.readFileSync('./pnpm-lock.yaml', 'utf8');
29+
const pattern = (name) => new RegExp(name + ':\\\s+specifier: [\\\s\\\w\\\.^]+version: (\\\d+\\\.\\\d+\\\.\\\d+)');
30+
const playwrightVersion = lockfile.match(pattern('playwright'))[1];
31+
console.log('PLAYWRIGHT_VERSION=' + playwrightVersion);
32+
"
33+
)" >> $GITHUB_OUTPUT
34+
35+
- name: Print versions
36+
shell: bash
37+
run: echo "${{ toJson(steps.resolve-package-versions.outputs) }}"
38+
39+
- name: Check resolved package versions
40+
shell: bash
41+
if: |
42+
contains(fromJSON('[null, "", "undefined"]'), steps.resolve-package-versions.outputs.PLAYWRIGHT_VERSION)
43+
run: echo "Failed to resolve package versions. See log above." && exit 1
44+
45+
- name: Cache Playwright v${{ steps.resolve-package-versions.outputs.PLAYWRIGHT_VERSION }}
46+
uses: actions/cache@v4
47+
id: playwright-cache
48+
with:
49+
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
50+
key: ${{ runner.os }}-playwright-${{ steps.resolve-package-versions.outputs.PLAYWRIGHT_VERSION }}
51+
restore-keys: |
52+
${{ runner.os }}-playwright-
53+
2054
- uses: actions/cache@v4
2155
with:
2256
path: |

.github/workflows/ci.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
pull_request:
88
workflow_dispatch:
99

10+
env:
11+
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.cache/ms-playwright
12+
1013
jobs:
1114
test:
1215
runs-on: ubuntu-latest
@@ -36,11 +39,19 @@ jobs:
3639
run: pnpm typecheck
3740

3841
- name: Install Playwright Dependencies
39-
run: pnpm exec playwright install chromium --with-deps
42+
run: pnpm exec playwright install chromium firefox --with-deps
4043

4144
- name: Test
4245
run: pnpm test
4346

47+
- name: Upload screenshots
48+
uses: actions/upload-artifact@v4
49+
if: failure()
50+
with:
51+
name: vitest-screenshots
52+
path: test/__screenshots__
53+
retention-days: 30
54+
4455
publish-preview:
4556
runs-on: ubuntu-latest
4657
if: ${{ false }} # TODO: Set up preview deployments

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
- minor
1212
- major
1313

14+
env:
15+
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.cache/ms-playwright
16+
1417
jobs:
1518
build:
1619
runs-on: ubuntu-latest

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ export default defineConfig({
3737
test: {
3838
browser: {
3939
enabled: true,
40-
provider: "playwright",
41-
instances: [{ browser: "chromium" }],
4240
},
4341
},
4442
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
"prettier": "^3.5.3",
5959
"tsup": "^8.4.0",
6060
"typescript": "^5.8.3",
61-
"vitest": "^3.1.1"
61+
"vitest": "^3.1.1",
62+
"webdriverio": "^9.12.5"
6263
},
6364
"prettier": {}
6465
}

0 commit comments

Comments
 (0)