Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve reporters passed down to the CLI relative to the running directory #3097

Merged
merged 4 commits into from
Mar 29, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/vitest/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,16 @@ export function resolveConfig(
resolved.related = toArray(options.related).map(file => resolve(resolved.root, file))

if (mode !== 'benchmark') {
// @ts-expect-error from CLI
const reporters = resolved.reporter ?? resolved.reporters
resolved.reporters = Array.from(new Set(toArray(reporters))).filter(Boolean)
// @ts-expect-error "reporter" is from CLI, should be absolute to the running directory
// it is passed down as "vitest --reporter ../reporter.js"
const cliReporters = toArray(resolved.reporter || []).map((reporter: string) => {
// ./reporter.js || ../reporter.js, but not .reporters/reporter.js
if (reporter[0] === '.' && (reporter[1] === '/' || reporter[2] === '/'))
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved
return resolve(process.cwd(), reporter)
return reporter
})
const reporters = cliReporters.length ? cliReporters : resolved.reporters
resolved.reporters = Array.from(new Set(toArray(reporters as 'json'[]))).filter(Boolean)
}

if (!resolved.reporters.length)
Expand Down