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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple output-files / Allow extension of existing reporters #1068
Comments
I like the suggested solution, if you can make it work 馃 |
I'm in the process of creating a Jetbrains run/debug configuration plugin for Vitest that would require me to create a custom reporter to emit messages in a format that the plugin framework understands. @sheremet-va would you be open to me creating a PR for @steve-py96 alternative solution? I'd love to bring first class support for Vitest to Jetbrains IDEs. |
How could we use this with custom reporters? Currently the Maybe it should allow package names of custom reporters as keys there. Vitest should then check if it's built in one - if not, import the given package and initialize it. Something similar as built-in ones have here: vitest/packages/vitest/src/node/reporters/index.ts Lines 11 to 19 in 978d37c
This Maybe this first PR should only address the built-in reporters. I'm happy to help extending this functionality to cover custom 3rd party reporters. |
Right, the custom reporters would actually work with the suggested changes. Simply with |
@AriPerkkio was thinking about the CLI too tho, the |
We can use dot-nested options: https://github.com/cacjs/cac#dot-nested-options |
Yeah, I think it's ok if we export |
Didn't check the used CLI lib, neat stuff 馃憣馃徔 |
@AriPerkkio @sheremet-va I have something working, similar to what @AriPerkkio mentioned:
To clarify this is for the CLI. The only issue I'm having at the moment is where to put tests for the added functionality? I don't really see any tests related to the CLI part of the vitest package. Do either of you have a preference? I want to make sure I have the go ahead and a test in place before putting in a PR. |
What do you mean? Don't we already have PR for this feature? I was waiting for @steve-py96 to make last changes before merging. |
@sheremet-va there has definitely been a mixup, potentially by me. I'm going to open a separate enhancement request to describe my scenario in detail. |
@sheremet-va sorry it was done already! I somehow managed to not push :(, it is up now |
Clear and concise description of the problem
Before going to the problem I have to... Thank for this awesome lib, you're doing an insanely great job 馃憤馃徔
The problem:
I have the case where I need the json and junit reporter at once (one dataset goes into some documentary, the other to gitlab), when using both they merge their results into the specified
outputFile
. Since I cannot access the default reporter classes (https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/reporters/json.ts f.e.) to overwrite some stuff I'd need to create a custom one by merging junit & json reporters which seems kinda cubersome.(sidenote: if the FR is not declined I'd try to contribute to this ofc, if I may :P)
Suggested solution
If
outputFile
would accept a Record in a format like{ [reporter]: outputFilePath }
(besides the string, the simple solution should ofc remain for the simple cases :D) the reporters could be run in parallel (would result in code likethis.ctx.config.outputFile.json || this.ctx.config.outputFile
ortypeof this.ctx.config.outputFile === 'string' ? this.ctx.config.outputFile : this.ctx.config.outputFile.json
or sth).Alternative
By exposing the default reporters somehow they could be overwritten (would result in code like
class MyCustomReporter extends JsonReporter { ... }
where the ctx could be overwritten at a certain point).Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: