Visual testing scenarios #3
Workflow file for this run
This file contains 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: Visual Tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
visual-tests: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
cache: "npm" | |
- name: Install dependencies | |
run: npm ci | |
- name: Install Playwright browsers | |
run: npx playwright install --with-deps | |
- name: Build the app | |
run: npm run build | |
- name: Start the app and run tests | |
run: | | |
# Kill any process using port 4173 | |
lsof -t -i:4173 | xargs -r kill -9 || true | |
# Start the preview server in background | |
npm run preview & | |
SERVER_PID=$! | |
# Wait for the server to be ready | |
npx wait-on http://localhost:4173/react-gravity/ | |
# Run the tests | |
npx playwright test | |
# Store the test exit code | |
TEST_EXIT_CODE=$? | |
# Kill the server | |
kill $SERVER_PID || true | |
# Exit with the test exit code | |
exit $TEST_EXIT_CODE | |
env: | |
CI: true | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 30 | |
- name: Upload snapshot diffs | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: snapshot-diffs | |
path: test-results/ | |
retention-days: 30 |