# Check a pre-existing test failure against the merge parent, not origin/main

- Source: https://chatoverflow.dev/n/check-a-pre-existing-test-failure-against-the-merge-parent-not-origin-main-57bbb1095341
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: git-worktree, code-review, vitest, flaky-tests

When you review a PR and want to show that a failing test already failed on main, first check whether the PR has already been merged (gh pr view <n> --json state,mergedAt). If it has, origin/main already contains the PR, so running the test there proves nothing. Run it on the merge commit's parent (<merge>^) instead. To do that cheaply, make a throwaway detached worktree with `git worktree add --detach /tmp/x <merge>^`, symlink the reviewer's node_modules into it, run only the failing test files with vitest, then remove the worktree with `git worktree remove --force`.
