-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
test_runner: print failing assertion only once with spec reporter #56662
Closed
+5
−782
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
test/fixtures/test-runner/output/assertion-color-tty.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,5 @@ | ||
✔ passes (*ms) | ||
✖ fails (*ms) | ||
Error: fail | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
|
||
ℹ tests 2 | ||
ℹ suites 0 | ||
ℹ pass 1 | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@pmarchini a simple fix for #56902 could be to set this to
true
when watch mode is enabled.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.
Makes sense! I'll take a look ASAP.
I think we should also add some tests to cover the report in watch mode
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.
@cjihrig How about allowing reporters to receive a watch mode flag via the constructor(if one exists)?
The alternative would be to use
getOptionValue('--watch')
, since we're in the internals, but off the top of my head, I don’t see a straightforward way for users to specify whether they’re in watch mode or not.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.
It is easy to detect from
process.execArgv
. I think it's fine to usegetOptionValue()
here. Ideally, reporters should behave the same regardless of watch mode. I just think this was a miss as part of this change because there was already a difference in behavior with watch mode. Right now I think we should aim to get this fixed ASAP in time for the next release.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.
Agreed!
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.
Okay, then I think we have two different issues:
SIGINT
, as a user might want to terminate the runner as soon as an error pops up to understand what's going on.Considering this is quite urgent, I would cover the "standard" use case (
--test --watch
) in a first PR viagetOptionValue()
, as the only alternative I see is allowing an option in the spec reporter constructor.WDYT?
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've thought about this a bit. I think the best course of action is:
'test:summary'
event, which is the last event emitted. This is not impacted by watch mode, so the inconsistency goes away. If this event were to ever be backported to Node 20, then all of this could be backported as well.'test:summary'
events. Print the list of errors here instead of in the_flush()
function. Also mark this change to only go back as far as the'test:summary'
event.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.
sounds like a plan 🚀
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'm checking the stream of events of a multi-file run with watch true and I see the following list of events
I think we should use
test:watch:drained
to correctly handle the watch use case, astest:summary
seems to be reported after each test file.Even if this means having the error details appear before the summary section, like this:
The alternative is to use
test:summary
, but only whendata.file === undefined
.wdyt?
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 left a comment on your PR, but I think you may want some logic in
runner.js
similar to what already exists for other events.