--changed
not picking up deep imports
#4933
Labels
p3-minor-bug
An edge case that only affects very specific usage (priority)
--changed
not picking up deep imports
#4933
Describe the bug
--changed
does not pick up deep changes.In the attached reproduction run
yarn vitest --run --changed=HEAD
add
will detect no specs to run. This is not expected 👎add-twice.ts
will detect no specs to run. This is expected 👍This is problematic for monorepo like setups (or any setup IMO). I expect the
--changed
flag to deeply look at dependencies to detect possible spec files to run. At moment this is shallow and only direct imports will cause files to change.It looks to me that the logic in
getTestDependecies
is trying to do this, as it recursively callsaddImports
, however the guard clause for checking if the dep is already added is preventing the deep lookup of depenendencies.getTestDependencies
LN: 401
adds the dep to the collected setLN: 403
invokes looking up further dependencies of that dependencyLN: 390
checks if that dependency is already added and bails outAs line 401 adds the collected dependency the further lookups of nested dependencies is not running. This causes the changed file dependencies to be shallow which does not accurately trigger related specs when a nested dependency is changed.
In order to correct the
changed
logic the logic needs to shift a little. Line 403 and 401 can't simply be shifted as otherwise it will cause any cyclic dependencies to cause a stack overflow. Aware that cyclic dependencies shouldn't exist in user code but having a cyclic dependency shouldn't cause vitest to crash.Reproduction
github.com/blake-newman/vitest-dev-vitest-kx8wc3
(I couldn't reproduce in stackblitz but checking out locally shows issue)
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: