Skip to content

Support agent detection with configured reporters #10217

@everett1992

Description

@everett1992

Clear and concise description of the problem

I like the Agent auto detection, but it's disabled if you configure any
explicit reporters. I want to enable junit and auto detection.

I don't want to depend on std-env myself (add a duplicate copy or rely
on npm hoisting), or duplicate the logic (what if vitest adds more good detection), but I might want to toggle other settings when running in an agent.

Suggested solution

Add a 'auto' (happy to bikeshed the name) reporter that has the same agent detection.

reporters: ['junit', 'auto'] // junit and default OR agent

For completeness vitest can also export isAgent from @vitest/config so configs can toggle other options, without depending on std-env.

https://github.com/everett1992/vitest/tree/auto-reporter

Alternative

The main alternative is importing std-env, or re-implementing isAgent check, but that's a bummer for shared configs, or when package versions of std-env drift.

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    P2 - 2

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions