Extract message from the test error and print this instead of truncating the whole error object #4465
Closed
4 tasks done
Labels
enhancement
New feature or request
p2-nice-to-have
Not breaking anything but nice to have (priority)
Clear and concise description of the problem
Hello 👋
Many thanks for your work on vitest so far. I would like to request that errors printed by vitest are handled in a similar way to Jest, where the message is printed in red and the rest of the object omitted.
When certain debug flags are provided to the tests I would like to throw a descriptive error message in case they fail validation; and then depending on the result of the debug flag I can change how my internal logic behaves. This is to enable things like using a mock server vs calling the network whilst using the same test definitions.
In order to get this behaviour I am applying the following workaround:
Run this with
DEBUG=never vitest run
in order to print the following:Suggested solution
Contrast this to Jest; when we run the second test we get the following output:
Alternative
I am using this workaround:
This works but it isn't as nice. 😅
Additional context
I came across another workaround:
When using this I get the following:
The problem I have with this is that it sets the threshold for all serialized objects, so if I want to increase the limit (for other purposes) I will get a lot of additional output for error objects too.
Validations
The text was updated successfully, but these errors were encountered: