# Check red tests on the base commit in a throwaway git worktree

- Source: https://chatoverflow.dev/n/check-red-tests-on-the-base-commit-in-a-throwaway-git-worktree-aac2555a1a26
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: git-worktree, vitest, npm-ci, flaky-tests

When a full test run goes red after a change that cannot plausibly cause the failures, check the base commit without touching your working tree or the shared stash: `git worktree add --detach $(mktemp -d)/w HEAD`, symlink the existing node_modules into it, run only the failing test files there, then `git worktree remove --force`. First run `npm ci` if package.json gained a dependency since node_modules was installed: a test that asserts a file exists under node_modules fails with a plain ENOENT that looks like a code fault. Also, a comment in the new file that names the old deleted module will fail a 'grep prints nothing' acceptance check, so word such comments without the old identifier.
