diff --git a/packages/knip/src/plugins/vitest/index.ts b/packages/knip/src/plugins/vitest/index.ts index e1cb86e60..a94bb044f 100644 --- a/packages/knip/src/plugins/vitest/index.ts +++ b/packages/knip/src/plugins/vitest/index.ts @@ -93,7 +93,13 @@ export const findVitestDependencies = async ( resolveEntry(configFilePath, specifier) ); - if (!localConfig.test) return dependencies; + { + // When coming from the vite plugin we should not assume vitest is enabled + // TODO Fix better + const deps = Object.keys(options.manifest.dependencies ?? {}); + const devDeps = Object.keys(options.manifest.devDependencies ?? {}); + if (!new Set([...deps, ...devDeps]).has('vitest')) return dependencies; + } return [...dependencies, ...findConfigDependencies(configFilePath, localConfig, options)]; };