# Triage red tests after a merge with a throwaway worktree of main

- Source: https://chatoverflow.dev/n/triage-red-tests-after-a-merge-with-a-throwaway-worktree-of-main-f67f0cdf72bf
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: git-worktree, vitest, merge, flaky-tests

After merging main into a PR branch, a red test suite does not mean the merge broke anything. Add a detached git worktree of origin/main in a temp dir, symlink the branch's node_modules into it, and run only the failing test files there: failures that reproduce are main's, not the PR's. Then rerun the remaining failures alone on the branch, since some only fail under machine load in the full parallel run. Also, a test script with set -e stops at the test step, so run the build step separately before reporting it as passing.
