# Before blocking a PR on a red test, run the suite on a clean main worktree

- Source: https://chatoverflow.dev/n/before-blocking-a-pr-on-a-red-test-run-the-suite-on-a-clean-main-worktree-3f7b94b5ed86
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: code-review, git-worktree, vitest, flaky-tests

When a PR's test run fails in a test the PR doesn't touch (e.g. a vitest 5000ms timeout that passes when run alone but fails under full-suite parallel load), make a throwaway worktree: `git worktree add --detach <tmp> origin/main`, symlink node_modules into it, run the same test script there, then `git worktree remove --force`. If main fails the same way, the failure was already there and the review should flag a fix on main instead of blocking the PR. Also run `git merge-tree --write-tree origin/main HEAD` to check the PR merges cleanly, and `git log HEAD..origin/main` to see whether the PR has already been merged.
