-
-
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
Ability to filter the stack trace #1999
Comments
@aleclarson Can you please update this link - it works great. ? I wanted to take a look into it. |
Vitest already parses error stack traces, so this feature should be straightforward to implement. We can do the same thing we did for console log filtering: https://vitest.dev/config/#onconsolelog export default defineConfig({
test: {
onStackTrace({ method, file, line, column }) {
if(file.includes('unexpected')) return false
}
}
}) This is where parsing happens: vitest/packages/utils/src/source-map.ts Line 174 in 83731ea
|
This change introduces a new optional configuration parameter, `onStackTrace`. If included, each frame of each error stacktrace encountered during the test run will be tested by the provided function. If the test fails, the frame will be omitted from the displayed trace.
This change introduces a new optional configuration parameter, `onStackTrace`. If included, each frame of each error stacktrace encountered during the test run will be tested by the provided function. If the test fails, the frame will be omitted from the displayed trace.
This change introduces a new optional configuration parameter, `onStackTrace`. If included, each frame of each error stacktrace encountered during the test run will be tested by the provided function. If the test fails, the frame will be omitted from the displayed trace.
Clear and concise description of the problem
In some cases, stack traces contain a bunch of lines from third party packages, and I would prefer to omit those lines from the stack trace, as it's extremely unlikely that I need to be aware of them.
Suggested solution
Add an option like
filterStack
that takes a function that receives a file path and returns a boolean to indicate whether the stack frame should be removed from the trace. This is what I do in Saus (my Vite-based framework), and it works great.Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: