-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow less verbose output #2976
Comments
Provide a reproduction for this claim please. Current solution is working correctly and is compatible with how Node.ja prints errors. |
@sheremet-va See screenshot below. The
I'm not saying this is a bug, I'm saying that the current logging behaviour is making it very awkward to use, and I can't find any existing functionality allowing the user to limit the verbosity. My only solution was to jump into |
I think you have to write your own reporter. Currently i use a very simple one like this: import c from 'picocolors'
import type { UserConsoleLog, Vitest } from 'vitest'
export default class VerboseReporter {
ctx!: Vitest
onInit(ctx: Vitest): void {
this.ctx = ctx
}
async onFinished(files = this.ctx.state.getFiles()) {
const logger = this.ctx.logger
for (const file of files) {
for (const task of file.tasks) {
if (task.result) {
if (task.result.state === 'pass') {
logger.log(c.gray(file.name), c.green('success'), task.name)
} else {
logger.error(c.gray(file.name), c.red('failed '), task.name)
}
}
}
}
}
onUserConsoleLog(log: UserConsoleLog) {
process[log.type].write(log.content)
}
} But it has no good error reporting (i manage errors in my app). Had only a quick look at the vitest reporters and i think they are not good to extend. @devs export the reporters. |
I use Nock and if nock fails to match a request the serialized output across a few failing tests can be so huge it can take half a minute to print it out and it cripples the terminal and i have to close the tab. I would also like to see flag to make this optional. |
We could pass vitest/packages/vitest/src/node/error.ts Lines 259 to 260 in fee7d8b
I think I understand the annoyance of huge |
Just wanted to add another perspective here: we have a use case where the Error object that gets thrown includes information about the HTTP request that was made that caused the error. This request object can include sensitive information such an access token, which we really don't want showing up in our CI logs. The normal Error toString implementation doesn't show the whole content of the Error object, but this serialized error output dumps the whole content of the object to console, including the sensitive information. We are looking for a way to suppress this verbose (Cc @mpodwysocki) |
Did you try Vitest 1.6.0? |
Yeah, I am using 1.6.0. I just saw in the CHANGELOG the new functionality of using |
Yes, we iterate over returned properties now (if it's an object) |
Clear and concise description of the problem
Currently, if a test fails, I see the error a total of 3 times, one time being a complete serialized representation of the error.
The most problematic of these is the serialized error.
In my use-case, I happen to be using Zod who's Error objects can be very large.
When every test run output ends with a serialized representation of a Zod error, I end up having to scroll up a page or more until I can see the normal vitest output.
This is what the output looks like for me:
Suggested solution
Would it make sense to have a flag making the output less noisy?
This seems to be the offending line:
vitest/packages/vitest/src/node/error.ts
Line 206 in 18d8019
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: