diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 609195e..cb0f8eb 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -6,20 +6,34 @@ on: branches: [main] jobs: test: + name: "Playwright Tests - ${{ matrix.project }}" + strategy: + fail-fast: false + matrix: + project: [chromium, firefox, webkit] timeout-minutes: 60 runs-on: ubuntu-latest defaults: run: working-directory: ./testing steps: + - uses: actions/cache@v2 + id: playwright-cache + with: + path: | + ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }} - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: lts/* + node-version: "18" - run: npm ci - run: npx playwright install --with-deps - - run: npm run precompile-elm-app - - run: npm test + if: steps.playwright-cache.outputs.cache-hit != 'true' + - run: npx playwright install-deps + if: steps.playwright-cache.outputs.cache-hit == 'true' + - run: npx elm make TestApp.elm --output=TestApp.html + - run: npx playwright test --project=${{ matrix.project }} - uses: actions/upload-artifact@v4 if: always() with: diff --git a/testing/README.md b/testing/README.md index 52de470..7f56171 100644 --- a/testing/README.md +++ b/testing/README.md @@ -1,11 +1,20 @@ # Snapshot testing ```bash -npm ci # installs the dependencies -npx playwright install --with-deps # installs automated browsers -npm run precompile-elm-app # precompiles the test app to `TestApp.html` -npm test # runs the snapshot tests -npm run update-snapshots # updates snapshots with chromium +# install the dependencies +npm ci + +# install playwright browsers +npx playwright install --with-deps + +# precompile the test app to `TestApp.html` +npx elm make TestApp.elm --output=TestApp.html + +# run the snapshot tests +npx playwright test + +# updates snapshots with chromium +npx playwright test --project=chromium --update-snapshots ``` - The tests are using [Playwright](https://playwright.dev) diff --git a/testing/package.json b/testing/package.json index 9aecb89..707505d 100644 --- a/testing/package.json +++ b/testing/package.json @@ -3,11 +3,7 @@ "version": "1.0.0", "description": "", "main": "index.js", - "scripts": { - "precompile-elm-app": "elm make TestApp.elm --output=TestApp.html", - "test": "npx playwright test", - "update-snapshots": "npx playwright test --project=chromium --update-snapshots" - }, + "scripts": {}, "keywords": [], "author": "", "devDependencies": {