-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
Added compact print option for default reporter #7845
Conversation
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.
Thanks! We can simplify how options are passed other than that this looks great!
We need an update to the changelog and an e2e test as well
@SimenB It turns out verbose reporter extends from default reporter. I was thinking that should verbose reporter receive |
Yeah, makes sense! |
When this lands, we should think about offering a way to activate this option via the CLI (not currently possible afaik) and/or add it to jest-watch-toggle-config. |
Currently no way of passing reporter options from the cli. Can do |
I'll add this to #7185 |
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.
We need to document these options somewhere
I think this will not work properly after there are >20 test suites. Summary reporter will kick in and print all the diffs anyway. Also what will the user need to do if he wants to know why those tests failed?
Or will rerunning tests without the @cpojer denied a very similar PR by @jeysal a year ago because it required the user to rerun tests #5676 (comment) @rickhanlonii was there an overview of proposed changes as you suggesetd in #3322 (comment)? IMHO this should be implemented in SummaryReporter by removing the 20 test suite threshold and then printing failed test names without the diffs. Probably enabled by some option? That way the order of output would be:
Currently SummaryReporter duplicates the diffs from DefaultReporter output, not sure how useful this is. |
I think a config option makes more sense than a CLI flag. We should pass the option to both verbose and default reporter. |
@SimenB Currently there is no any built-in reporter that receives options. So shall we create separate page for them for documentation? |
A separate page for reporters would be awesome! Then we can go a bit in depth about the API and link to some cool community-made reporters (neither of which are needed for a first iteration, of course!) |
As an aside, on the "standard vs verbose" reporter thing - I think at some point we want to only allow a single reporter to actually print to stdout. And custom reporters would have to either implement the whole thing (e.g. by extending the built-in one) or export React components. The dream is to rewrite reporters to Ink (I have a working PoC here: https://github.com/SimenB/jest/tree/ink-reporter), but that doesn't work well with multiple reporters wanting control of So at that point, "default jest reporter" would decide whether or not do print a summary, it wouldn't be decided by Jest by plugging in a different reporter (standard vs verbose). However, that's future (and undecided) stuff! EDIT: Since I was on a roll: #7900 |
: new DefaultReporter( | ||
this._globalConfig, | ||
this._getReporterOption('default'), | ||
), |
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.
SummaryReporter (line 304) will still print diffs when there will be more than 20 test suites.
@SimenB the previous PR was denied by @cpojer mainly because user had to rerun tests in order to see why they failed, not because it was implemented through CLI flag. If I understand correctly it's is the same situation here, maybe even worse, because now in order to see the diffs you will need to rerun tests with a different jest config (without 'compact' enabled on default reporter). So you will need a separate npm script with If I am wrong here please explain why. @doniyor2109 the full failure messages will still be printed by SummaryReporter when there will be more than 20 test suites. So your implementation fails to achieve its main goal which is to stop the failureMessage spam which makes it hard to understand what tests actually failed. @rickhanlonii was there a proposed changes overview like you wanted in #3322 (comment)? |
Sorry about the conflict 😬 I've extracted the reporters to their own package instead of living inside I think the behavior we want is to get some sort of minimal output showing the errors. Maybe instead of the full I'd like to take a small step back and frame this in a way that we only think about a single reporter (that behaves like the current way default + summary behaves), not separate reporters. How would we expect it to print the errors (compact or not)? @pedrottimark you've worked a lot on clearer error messages lately, any thoughts on this? |
Co-Authored-By: doniyor2109 <doniyor2109@gmail.com>
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.
Sorry about the random driveby comments
We talked about this now and the way we want to do it is basically remove the error details from the summary reporter. So the summary reporter should just print names of the failed tests instead of the error details. So this part should essentially not print
I think the 20 limit still makes sense? No need to use space for a summary if we don't have a lot of output I think this solves the issue of duplication and a lot of extra output that's basically duplication. Not sure if it makes sense as a default option since there might be thousands and thousands of tests, and having to scroll past the passing ones to find it might be annoying? Behind an option makes sense, though ( @jeysal @thymikee @mattphillips agreed? |
As a user I would definitely want the 20 suite limit removed. Even 1 suite can have enough failing tests to blow up the output. And I believe the space would be used minimally and for relative information. Honestly I came to a conclusion that just adding a new list of failing test names that would always be printed above the summary (the one with the numbers) and not changing anything else would be a good simple solution. Like @pedrottimark mentioned in his comments. It would solve all the cases without losing any usability and there would be no need for any extra config options. EDIT: This is @sunfit, forgot i was logged in with a different github acc, sorry. |
The 20 limit is for printing a summary at all, if it's less than 20 we output nothing (in the summary). So I think we're in agreement? Summary should just be a list without details as the details will be in the normal output. Sorry if I misunderstood something |
That is the problem. If we output nothing then we won't output the list of failed test names. For example I wished for this feature long before my project had 20 suites. About 10 diffs of failing tests already bloat the output so that a lot of scrolling is required to see the "big picture" - all the failing tests. |
Right, you always want the list? Gotcha. Maybe a |
I think this behaviour is essential enough to be available by default, also the less options there are the better is for the user. However I would be content with having it behind some option as well. |
What happened with the work on this PR? Is it still relevant to complete? Or has this feature been completed in some other PR? |
No idea. Did you read the whole thread? The implementation should probably differ from what is in this PR. |
Should this be a custom reporter instead, like |
The discussion about this went across a few tickets. Mainly here and in #3322 I was hoping for this behaviour to be available out of the box in jest. Prefered order of things (as seen in the screenshot) is:
Screenshot is just an example to illustrate the order, some improvements are in order for the actual output. Failed tests should be at the bottom of the list for example (in case there are hundreds of passing suites), maybe passing suites should not be shown at all, or shown before the diffs, some kind of heading for the list summary, etc. I could try to do a PR with this implemented behind an option or as default behaviour. |
Alternatively, would it be simpler to use the existing reporter but with a |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Added
compact
option to DefaultReporter so that it will prints only paths and titles.Resolves #3322
Test plan