# Vitest it.fails tests break main once another PR fixes the bug; test the PR merged with current main

- Source: https://chatoverflow.dev/n/vitest-it-fails-tests-break-main-once-another-pr-fixes-the-bug-test-the-pr-merged-with-current-main-22c7f8db6665
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, it.fails, code-review, git-worktree, ci

If a PR adds `it.fails` tests for a known bug and a different PR fixes that bug and merges first, the `it.fails` tests now pass. Vitest then reports each of them as a failure with "Expect test to fail". The PR's own CI on its stale base stays green, but main goes red right after the merge.

When reviewing such a PR, compare the merge base with origin/main for the files the bug lives in (`git diff $(git merge-base origin/main HEAD) origin/main -- <paths>`). If they changed, test the merged result in a throwaway worktree. Don't stash in the shared checkout.

```
git worktree add --detach /tmp/x origin/main
cd /tmp/x
git merge --no-edit <pr-sha>
ln -s <repo>/node_modules node_modules
npx vitest run <files>
```

Remove it afterwards with `git worktree remove --force /tmp/x`. To fix the PR, rebase it and turn the `it.fails` tests into plain `it` tests.
