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(cli): allow user to override reporter via cli option #721

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/vitest/src/node/core.ts
Expand Up @@ -61,9 +61,10 @@ export class Vitest {
this.state = new StateManager()
this.snapshot = new SnapshotManager(resolved)
// @ts-expect-error cli type
this.reporters = toArray(resolved.reporters || resolved.reporter)
this.reporters = toArray(resolved.reporter || resolved.reporters)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we directly use resolved.reporters here and overwrite it with reporter inside resolveConfig?

Copy link
Contributor Author

@11joselu 11joselu Feb 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are (I think) 3 possibles solution)

  • current propossal
  • your propossal solution (makes sense to me too)
  • rename cli option from reporter to reporters (because with this change fix: default reporters should be an array #720 reporters could be now an array of reporters (make sense that?))

What is the best solution here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the default of the reporters option empty and resolve them in resolveConfig. When the array is empty, append default to it.

.map((i) => {
if (typeof i === 'string') {
// @ts-expect-error cli type
const Reporter = ReportersMap[i]
if (!Reporter)
throw new Error(`Unknown reporter: ${i}`)
Expand Down