Increase Playwright test reliability #611
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: 'E2E Tests' | |
on: [pull_request] | |
env: | |
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} | |
jobs: | |
tests_e2e_netlify_prepare: | |
name: Wait for deployment on Netlify | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Retry Netlify Deployment | |
run: | | |
retries=5 | |
count=0 | |
until $(curl --output /dev/null --silent --head --fail https://deploy-preview-${{ github.event.pull_request.number }}--eventua11y.netlify.app/); do | |
((count++)) | |
if [ ${count} -ge ${retries} ]; then | |
echo "Max retries reached, failing the job." | |
exit 1 | |
fi | |
echo "Netlify site not ready, retrying in 60 seconds..." | |
sleep 60 | |
done | |
env: | |
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} | |
tests_e2e_netlify: | |
needs: tests_e2e_netlify_prepare | |
name: Run end-to-end tests on Netlify PR preview | |
runs-on: ubuntu-latest | |
container: | |
image: mcr.microsoft.com/playwright:v1.40.0-jammy | |
timeout-minutes: 15 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
- name: Install dependencies | |
run: npm ci | |
- name: Verify network connectivity | |
run: | | |
echo "Testing connection to Netlify preview..." | |
curl -v https://deploy-preview-${{ env.GITHUB_PR_NUMBER }}--eventua11y.netlify.app/ | |
echo "Testing DNS resolution..." | |
nslookup deploy-preview-${{ env.GITHUB_PR_NUMBER }}--eventua11y.netlify.app | |
- name: Run tests | |
env: | |
PLAYWRIGHT_TEST_BASE_URL: 'https://deploy-preview-${{ env.GITHUB_PR_NUMBER }}--eventua11y.netlify.app/' | |
DEBUG: 'pw:api,pw:browser*,pw:protocol*' | |
CI: 'true' | |
run: | | |
echo "Starting Playwright tests..." | |
npx playwright test --project=chromium --retries=5 --reporter=list |