Add playwright branch workflow trigger #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run e2e tests | |
| on: | |
| push: | |
| branches: [main, master, playwright] | |
| pull_request: | |
| branches: [main, master] | |
| env: | |
| AUNTY_HOST: localhost # This tells aunty to serve on localhost | |
| TERMINUS_FETCH_API_KEY: ${{ secrets.TERMINUS_FETCH_API_KEY }} | |
| jobs: | |
| e2e: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - run: npm ci | |
| - run: npx playwright install --with-deps | |
| - run: echo "TERMINUS_FETCH_API_KEY=$TERMINUS_FETCH_API_KEY" > .env | |
| - name: Run Playwright tests | |
| run: | | |
| npm run test | tee output.log | |
| if grep -q -e "Error: A snapshot doesn't exist at" -e "Screenshot comparison failed" output.log; then | |
| echo "Playwright tests failed due to a snapshot issue." | |
| echo "SNAPSHOT_DIFFERENCES=true" >> $GITHUB_ENV | |
| exit 1 | |
| elif grep -q "failed" output.log; then | |
| echo "Playwright tests failed due to a non-snapshot issue." | |
| exit 1 | |
| fi | |
| - uses: actions/upload-artifact@v4 | |
| id: artifact-upload | |
| if: ${{ !cancelled() }} | |
| with: | |
| name: playwright-report | |
| path: playwright-report/ | |
| retention-days: 30 | |
| - name: Comment on PR with report link | |
| uses: thollander/actions-comment-pull-request@v3 | |
| if: ${{ failure() && env.SNAPSHOT_DIFFERENCES == 'true' }} | |
| with: | |
| message: | | |
| ### Playwright visual snapshot differences were detected. | |
| View the [Playwright report](${{ steps.artifact-upload.outputs.artifact-url }}) to review the visual differences. | |
| **To approve the snapshot changes and update the snapshots, please comment:** /approve-snapshots |