Running tests on every pull request is the highest-impact change you can make to a CI pipeline. Bugs caught at PR review cost minutes to fix. Bugs caught in production cost hours, plus the trust of whoever found them.
This playbook covers how to wire up PR-triggered E2E tests using GitHub Actions and Playwright, how to block merges until those tests pass, and exactly when to add a human verification step before a PR goes green.
How do you run tests on every pull request?
The pull_request trigger in GitHub Actions runs your workflow automatically whenever a PR is opened, updated with new commits, or reopened. According to the GitHub Actions documentation, this covers the opened, synchronize, and reopened activity types by default. That means every commit pushed to a PR branch re-triggers the full test suite without any manual action.
The Playwright CI docs generate this starter workflow when you run npm init playwright@latest and choose to add a GitHub Actions workflow. It creates .github/workflows/playwright.yml with the PR trigger already configured:
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v5
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
Four things to note in this config:
- The
pushtrigger on main is separate frompull_request. Keep both. The push trigger re-confirms the merge commit is clean after the PR lands. timeout-minutes: 60is Playwright's recommendation. Long-running E2E suites hang silently in CI without a hard timeout.npx playwright install --with-depsinstalls browser binaries and their OS-level dependencies in one step. Skip this and the run fails with a cryptic missing-library error.upload-artifactwithif: ${{ !cancelled() }}preserves the HTML trace report even on a failed run, which is where you find out what actually broke.
If you want to skip the workflow on draft PRs (common for in-progress branches), add types: [opened, synchronize, reopened, ready_for_review] and a filter:
on:
pull_request:
branches: [ main ]
types: [ready_for_review, synchronize, reopened]
The ready_for_review type fires when a draft is promoted to review-ready. The workflow will not run while the PR stays in draft.
How do you gate merges on end-to-end tests?
Require the Playwright workflow job as a status check on your main branch. Until every required check passes, GitHub blocks the merge button. According to the GitHub branch protection docs, required status checks must reach a successful, skipped, or neutral state before any collaborator can merge.
Step-by-step:
- Push the
playwright.ymlfile and open at least one PR so the job name appears in GitHub's status check registry. - Go to your repo: Settings, then Branches, then Add a branch protection rule.
- Set the branch name pattern to
main(ormaster). - Check "Require status checks to pass before merging."
- In the search field, type the name of your workflow job (in the example above:
test). Select it. - Check "Require branches to be up to date before merging" (GitHub calls this strict mode). This prevents a PR from merging when the base branch has moved forward since the tests last ran.
- Save.
After this, every PR to main shows a required check. Contributors cannot merge until the check turns green.
One naming pitfall: if you have multiple workflows with a job named test, GitHub's status check search returns both, and requiring the wrong one blocks PRs without an obvious reason. Name jobs specifically:
jobs:
e2e-playwright:
...
Then require e2e-playwright in branch protection.
For teams using GitHub's merge queue (introduced in 2023 and available on Team and Enterprise plans), add merge_group as an additional workflow trigger. Without it, the required check does not fire when a PR enters the queue and merges fail silently:
on:
pull_request:
branches: [ main ]
merge_group:
How do you trigger tests via webhook for external QA systems?
If your test runner lives outside GitHub (a hosted QA service, a self-managed Playwright cluster, or a hybrid QA platform), use GitHub's repository_dispatch event to call it from a PR workflow, or use GitHub webhooks to push PR events to an external endpoint.
Option 1: repository_dispatch from within a workflow
This sends an event to your QA system the moment a PR opens, then waits for it to post a commit status back:
name: Trigger External QA
on:
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened]
jobs:
trigger-qa:
runs-on: ubuntu-latest
steps:
- name: Dispatch to QA platform
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.QA_DISPATCH_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/dispatches \
-d '{
"event_type": "pr-qa-run",
"client_payload": {
"pr_number": "${{ github.event.pull_request.number }}",
"sha": "${{ github.event.pull_request.head.sha }}",
"branch": "${{ github.head_ref }}"
}
}'
Option 2: GitHub webhook to an external endpoint
Go to your repo Settings, then Webhooks, then Add webhook. Set the payload URL to your QA platform's endpoint, choose application/json, and select the Pull requests event. GitHub sends a POST request with the full PR payload whenever the PR is opened or updated. Your QA system reads the head.sha from the payload, runs tests against that commit, and posts a commit status back via the GitHub Commits API (POST /repos/{owner}/{repo}/statuses/{sha}). That status check then appears in the PR and participates in branch protection.
The advantage of Option 2 is that your QA platform controls the full lifecycle (receive event, run tests, report status) without needing a GitHub-hosted runner in the loop. This is the pattern Simz uses: a PR open event hits the webhook, AI test agents run the critical flows, and the result posts back as a commit status. If a human tester needs to verify the result, that step happens before the status is marked passing.
When should you add the @mention-a-human verification step?
PR-triggered AI tests run fast and confirm the happy path works. That is exactly what they are good at. The green != correct problem shows up on flows where the test did not know what to check, because the engineer who wrote the test also wrote the code and shares the same blind spots.
Add a human verification step to your merge gate for these specific cases:
Payment flow changes. A Playwright test confirms the form submits and a success screen appears. It does not confirm the webhook fired, the subscription state updated, or the charge appeared in Stripe with the correct metadata. A human tester running the full flow in live mode with a real card catches those gaps. Make this a required step before any PR that touches billing code.
Auth state changes. Password reset, session expiry, MFA enrollment, logout-on-another-device. These flows are hard to test correctly in an automated runner (timing, email delivery, cross-session state) and the blast radius of a bug is high. A human pass through the changed flows takes under 10 minutes and catches the failure mode that ships as "the bug my first user found."
After any AI-generated code change. AI writes the happy path. The test suite it writes confirms the happy path passes. This is the definition of test theater: everything is green, the code ships, and a real user finds the edge case within 24 hours. A second set of eyes from someone who did not build the feature breaks this loop.
Before any public launch or feature flag rollout. See the critical flows checklist for the specific flows worth verifying before a release.
The practical implementation is a required reviewer assignment on the PR, not a separate pipeline step. When the automated checks pass, your QA engineer is @mentioned (or automatically assigned as a reviewer) and does a short manual pass on the specified flows. They approve the PR when satisfied. The branch protection rule requires both the automated check AND the reviewer approval before merge is allowed.
For a deeper look at why AI-only test suites accumulate this kind of coverage debt, the pillar guide QA without a QA team covers the full picture of building a QA process when you have no dedicated QA headcount.
How do you keep a PR test suite fast enough to actually use?
A test suite that takes 25 minutes to run on every PR gets disabled within a week. These three changes keep it under 5 minutes for most apps:
Shard across parallel jobs. Playwright has native sharding support. Split a 100-test suite across 4 jobs and each runs 25 tests in parallel. The Playwright CI sharding docs show the matrix strategy for this:
jobs:
test:
strategy:
matrix:
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- run: npx playwright test --shard=${{ matrix.shard }}
Run only the flows that changed. Use paths filters to skip E2E tests when only documentation or non-app files changed:
on:
pull_request:
branches: [ main ]
paths:
- 'src/**'
- 'package.json'
- 'playwright.config.ts'
Separate smoke from full regression. On every PR, run a smoke suite of your 10-15 most critical flows. Run the full regression on merge to main or on a nightly schedule. PRs stay fast; regressions still get caught. The playwright-flaky-tests guide covers the other half of this: once your suite is fast, keeping it stable is the ongoing cost that most teams underestimate.
What does the full setup look like end-to-end?
Here is the complete pattern for a team with no existing CI for E2E tests:
- Add
.github/workflows/playwright.ymlwith thepull_requesttrigger as shown above. - Set the job name to something specific (
e2e-playwright, nottest). - Push a PR, confirm the job runs and appears in the PR status section.
- Add a branch protection rule on
mainrequiringe2e-playwrightto pass. - Test the gate: break a test intentionally in a PR branch. Confirm the merge button is blocked.
- Decide which flows require a human pass. Add reviewer assignment rules for those PRs (in GitHub: Settings, then Branches, then require X approvals, or assign via
CODEOWNERS). - For external QA platforms, configure the webhook pointing at your QA provider's endpoint and confirm the commit status posts back to the PR.
- Check /pricing if you want AI test agents and a human QA engineer included without standing up your own Playwright infrastructure.
The whole setup takes an afternoon. The alternative is "deploy and pray" on every merge, which costs a production incident at some point and hours of debugging after.
Simz runs both AI test agents and human QA engineers on every PR for teams that want this gate without maintaining the infrastructure themselves. Claim 5 free test runs to see what your current PRs would catch before they merge.