Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(cli): allow overrides reporter via cli option (#2573)
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
fix #2537
  • Loading branch information
mysteryven committed Jan 1, 2023
1 parent 8d64790 commit 894f155
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/vitest/src/node/config.ts
Expand Up @@ -198,11 +198,9 @@ export function resolveConfig(
resolved.related = toArray(options.related).map(file => resolve(resolved.root, file))

if (mode !== 'benchmark') {
resolved.reporters = Array.from(new Set([
...toArray(resolved.reporters),
// @ts-expect-error from CLI
...toArray(resolved.reporter),
])).filter(Boolean)
// @ts-expect-error from CLI
const reporters = resolved.reporter ?? resolved.reporters
resolved.reporters = Array.from(new Set(toArray(reporters))).filter(Boolean)
}

if (!resolved.reporters.length)
Expand Down
6 changes: 6 additions & 0 deletions test/reporters/tests/custom-reporter.spec.ts
Expand Up @@ -71,4 +71,10 @@ describe.concurrent('custom reporters', () => {
const stdout = await runWithRetry('--config', 'without-custom-reporter.vitest.config.ts', '--reporter', customJSReporterPath)
expect(stdout).includes('hello from custom reporter')
}, TIMEOUT)

test('overrides reporters by given a CLI argument --reporter works', async () => {
const stdout = await runWithRetry('--config', 'deps-reporter.vitest.config.ts', '--reporter', customJSReporterPath)
expect(stdout).not.includes('hello from package reporter')
expect(stdout).includes('hello from custom reporter')
}, TIMEOUT)
})

0 comments on commit 894f155

Please sign in to comment.