Skip to content
RecipesDoc

Test Each Pull Request's Preview URL (Vercel, Netlify)

Your CI points a Certyn "preview" environment at the PR's preview URL, then runs your smoke tests there and fails the job when they fail.

For teams whose host builds a preview site for every pull request and who want Certyn to test that site, not staging.

Your setup

  • Vercel, Netlify or a similar host makes a preview URL per pull request.
  • GitHub Actions (or another CI that can run curl).
  • Certyn test cases for your critical paths, tagged smoke.

Say this to Certyn

Vercel makes a preview URL for each PR. Test that preview with our smoke tests and fail the PR job if they fail.

What Certyn does

  1. Creates a preview environment (app.environment.create). You approve. Its URL changes with each PR.
  2. Saves the test account for that environment with the sign-in form, if previews need one.
  3. Lists your smoke test cases, or proposes a few for your critical paths.
  4. Gives you the workflow below. With a saved GH_TOKEN that has the workflow permission, it can open a PR with the file.

You create one API key in Settings → API Keys with the Platform Operator preset: it has the CI scopes and Projects, which changing an environment needs. The ci_setup form's key cannot change environments.

on: deployment_status
concurrency:
  group: certyn-preview
  cancel-in-progress: false
jobs:
  certyn:
    if: github.event.deployment_status.state == 'success' && contains(github.event.deployment.environment, 'Preview')
    runs-on: ubuntu-latest
    steps:
      - name: Point Certyn's preview environment at this PR
        env:
          PREVIEW_URL: ${{ github.event.deployment_status.environment_url }}
        run: |
          curl -sSf -X PUT "https://api.certyn.io/api/projects/${{ vars.CERTYN_PROJECT_ID }}/environments/${{ vars.CERTYN_PREVIEW_ENV_ID }}" \
            -H "Content-Type: application/json" -H "X-API-Key: ${{ secrets.CERTYN_API_KEY }}" \
            -d "{\"baseUrl\":\"$PREVIEW_URL\"}"
      - uses: certyn-one/action@v1
        with:
          api_key: ${{ secrets.CERTYN_API_KEY }}
          project_slug: ${{ vars.CERTYN_PROJECT_SLUG }}
          environment_key: preview
          tags: smoke

Vercel reports each preview as a GitHub deployment, so this workflow starts when the preview is ready. With Netlify or another host, run the same two steps after your deploy step, with the preview URL it gives you. Find the two ids once with GET /api/projects/overview and GET /api/projects/{projectId}/environments.

What you get

  • A run on the PR's own preview, with a run report and a Certyn issue per real product bug.
  • A failed job when a smoke test fails or is blocked.

Limits

  • One PR at a time. A run reads the environment's URL when each test starts, so a second PR would change it mid-run. The concurrency group makes PRs wait. GitHub keeps only one waiting job per group, so a newer one replaces it: re-run a skipped job.
  • The Certyn GitHub App does not test preview URLs. Its rules run against the environment's saved URL; a deployment's URL is only a link on the run.
  • The Projects scope can also change and delete projects. Keep the key in a protected secret.
  • Certyn opens the preview like a visitor. If previews need a Vercel or Netlify login, turn that off for previews or use your host's bypass for automation.
  • For a goal instead of a suite, send the preview URL in the action's instruction. Certyn can start a run with that URL in its goal, but the job does not gate on that run.