Skip to content

Let AI choose which tests to run on pull requests

Suppose your team runs the full Playwright suite on main. You can keep that check after merging and let TestPerch choose tests for each pull request based on what it changes.

  1. As a workspace owner or admin, connect the GitHub repository to your TestPerch project. Make sure the PR workflow reports its Playwright results.
  2. Have a workspace owner turn on AI in Workspace settings → AI. The owner can also set a monthly spending limit.
  3. In Project settings → Environments → Pull requests, create an environment named PRs into main with the target branch pattern ^main$, or use an existing one for that branch. Substitute your team’s target branch if it differs. Map branch and pull-request runs
  4. In Project settings → AI, turn on Enable AI test selection. Under Target environments, select PRs into main and save. Leave the branch environment for pushes to main unchecked to keep running the whole suite there.
  5. Open or update a pull request targeting main and let its Playwright workflow run. Find the TestPerch comment on GitHub. AI optimization tells you whether it chose all, some, or none of your spec files. Why explains the decision for that change.

If there’s a check you want on every pull request, such as sign-in, you can tell TestPerch to always run it. You can also run the whole suite for one PR.