Skip to main content
By default, every test run uses the test code on the test repository’s default branch. When a feature changes the UI, its tests have to change too, but only for runs of that feature: the same change would fail against a deployment that doesn’t have the feature yet. Branching keeps test changes on a test branch with the same name as the application branch. Runs for that feature use the test branch, and Empirical merges it into the default branch when the application branch merges. Without branching, a preview deployment of a feature runs the default branch's tests and fails With branching, the preview deployment runs the matching test branch

Which test code a run uses

Test runs never create a test branch. It must already exist in the test repository.

Pull request runs

A run triggered for an application pull request tests the test code as it will look once that pull request merges. Empirical merges the matching test branch into the default branch on a temporary test-run/merge/* ref and runs the merge commit. It deletes these refs after the test branch merges. If the test branch conflicts with the default branch, the run errors with a merge conflict. Rebase the test branch, or pass branch to run it without a merge. The dispatch action sends the trigger on pull_request workflow events. With the API, send trigger together with build:

Choose the default branch

New projects use main. To change it, open Settings → General. Pick the branch your application merges features into. For example, if features merge to a staging branch in your application repository, name the Empirical default branch staging too.

Merge test branches with application branches

When an application pull request merges, Empirical needs to merge the matching test branch into the same base. Add a merge step to your CI so Empirical hears about the merge. It sends only the branch names, not your application code. Empirical deletes the test branch after it merges. Empirical merges only an open, ready-for-review pull request from the test branch into that base. If the test branch has no open pull request, or its pull request is a draft, nothing merges. To keep a test change out of the default branch, close its pull request or mark it as a draft.

GitHub Actions

Add this workflow to .github/workflows/merge-branches.yaml. The action reads the head and base branch from the pull_request event:
v1 receives backwards-compatible fixes, and breaking changes ship as a new major version. To pin an exact release, use a tag such as v1.0.0.

Other CI/CD providers

Call the merge-branches API after the application pull request merges. Set HEAD_BRANCH to the branch that merged and BASE_BRANCH to the branch it merged into: