From b43a9030c4befc115e3d246de70543d76cb89db4 Mon Sep 17 00:00:00 2001 From: Lars Kappert Date: Mon, 4 Dec 2023 19:22:08 +0100 Subject: [PATCH] Fix test for absence of test config in vitest plugin --- packages/knip/src/plugins/vitest/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)]; };