diff --git a/packages/knip/fixtures/plugins/vitest7/package.json b/packages/knip/fixtures/plugins/vitest7/package.json index 294a62634..0cfbc15cd 100644 --- a/packages/knip/fixtures/plugins/vitest7/package.json +++ b/packages/knip/fixtures/plugins/vitest7/package.json @@ -1,6 +1,8 @@ { "name": "@fixtures/vitest7", "devDependencies": { - "vitest": "*" + "vitest": "*", + "ReporterString": "*", + "ReporterArray": "*" } } diff --git a/packages/knip/src/plugins/vitest/helpers.ts b/packages/knip/src/plugins/vitest/helpers.ts index f424162fd..ad15d8c84 100644 --- a/packages/knip/src/plugins/vitest/helpers.ts +++ b/packages/knip/src/plugins/vitest/helpers.ts @@ -45,6 +45,6 @@ export const getExternalReporters = (reporters?: ViteConfig['test']['reporters'] reporters ? [reporters] .flat() - .flat() + .map(reporter => (Array.isArray(reporter) ? reporter[0] : reporter)) .filter((reporter): reporter is string => typeof reporter === 'string' && !builtInReporters.includes(reporter)) : []; diff --git a/packages/knip/test/plugins/vitest7.test.ts b/packages/knip/test/plugins/vitest7.test.ts index f0423673c..d342baedc 100644 --- a/packages/knip/test/plugins/vitest7.test.ts +++ b/packages/knip/test/plugins/vitest7.test.ts @@ -8,19 +8,15 @@ import baseCounters from '../helpers/baseCounters.js'; const cwd = resolve('fixtures/plugins/vitest7'); test('Find dependencies with Vitest plugin (7)', async () => { - const { issues, counters } = await main({ + const { counters } = await main({ ...baseArguments, cwd, }); - assert(issues.unlisted['vitest.config.ts']['ReporterString']); - assert(issues.unlisted['vitest.config.ts']['ReporterArray']); - assert.deepEqual(counters, { ...baseCounters, files: 0, processed: 3, total: 3, - unlisted: 2, }); });