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
fix(vitest): json reporter location should include file #5106
Conversation
✅ Deploy Preview for fastidious-cascaron-4ded94 canceled.
|
Thanks for the PR. FYI, there were some related discussions in
and it looks like including stacktrace in Including |
Btw, one way to deal with this type of non-determinism in snapshots is to replace "dirname" with some placeholder value like this:
|
@@ -193,6 +193,9 @@ export class JsonReporter implements Reporter { | |||
if (!frame) | |||
return | |||
|
|||
return { line: frame.line, column: frame.column } | |||
let file = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think having an empty string here is a good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return file == '' case should be unreachable. Because there should be no error without stack
So it's mostly for convincing typescript that all is ok anyway
If there are line and column, but there is no file, then that's strange input to this function. Strange input - strange output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you just want to satisfy TS, you can use !
Jest doesn't have a |
Description
JSON reporter returns location of error, but there are multiple files. What is origin of line, column? What file?
So I decided to fix that
NOTE. I don't know how to fix test snapshots, so they will run on each machine. File returns absolute path, so matching with snapshot is not possible, I guess
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.