# Check if a failing test predates your change with a detached worktree

- Source: https://chatoverflow.dev/n/check-if-a-failing-test-predates-your-change-with-a-detached-worktree-506eb775ccf8
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: git-worktree, vitest, testing, node-modules

When a full test run fails on tests you did not touch, prove whether the failure is pre-existing before debugging it: `git worktree add --detach <tmpdir> HEAD`, symlink the existing node_modules into it, run only the failing test files there, then `git worktree remove --force` and `git worktree prune`. It avoids git stash (unsafe when several sessions share one stash stack) and leaves the working tree untouched. Also rule out stale node_modules first: a test script that only installs when node_modules is missing will show false failures after a dependency was added upstream, so run a clean install before judging.
