Skip to content
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 --detailInfo switch #92

Closed
wants to merge 6 commits into from
Closed

Added --detailInfo switch #92

wants to merge 6 commits into from

Conversation

johanneslumpe
Copy link

As discussed with @jeffmo this is my first stab at incorporating a switch to display more detailed information, i.e. all tests run, instead of just the final result/fail.

I also took the liberty to rewrite the test result handler for now be a configurable class, which for now only supports showing detailed information or the default output, but could be enhanced to show pending tests etc. (which is something I really want, since it's a good way to keep track of what still has to be done)

I assume this PR will be a work in progress, but I thought I'd put it out there, before continuing further to see what you guys feel about it.

With the --defailInfo switch enabled, a test suite could look like this:
image

@@ -190,9 +192,9 @@ function runCLI(argv, packageRoot, onComplete) {
['Found', numMatchingTestPaths, 'matching', (numMatchingTestPaths > 1 ? 'tests...' : 'test...')].join(' ')
);
if (argv.runInBand) {
return testRunner.runTestsInBand(matchingTestPaths, _onResultReady);
return testRunner.runTestsInBand(matchingTestPaths, _onResultReady.bind(null, argv));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really have a lint for this, but internally our style guide is to keep lines at 80chars or less. Could you split this onto multiple lines?

@jeffmo
Copy link
Contributor

jeffmo commented Sep 4, 2014

I'm sorry it took so long to get back on this -- I've been moving and vacationing (and now, hitting the ground running/catching up on all the things I missed in that time).

In any case, this looks great. Also, here's come context around how things are structured that are relevant to this change:

One of the reasons the bin/jest.js file is mostly separate from TestRunner.js is because I wanted Jest to be built as a library...right up until the very top level where you need to actually interface with it somehow (via a CLI, in 99% of the cases). In the interest of completeness I included the bin/jest.js CLI as the default interface. However, it should still be possible (and normal) for various platforms to be able to define their own interfaces and CLIs using those libraries. For example, you could imagine a CLI that reports results through a page served up over a web server rather than through a command interface...or even one that reports results out to a back-end test result aggregation system (which is similar to what we have at FB).

So with that context in mind, the goal for src/defaultTestResultHandler.js was to be be a result handler used for that default CLI (bin/jest.js). If someone needed to write their own CLI, they might use it....but they might also not use it at all (as is the case for Facebook, where we have fb-specific flags and output formats that we need to support -- as well as those test result logging/aggregation systems I mentioned a little earlier).

Anyway, I think it's fine if we want to generalize defaultTestResultHandler a bit, but I think it'll be hard to support every possible way various platforms want to surface results...so I don't want us to go too far and try to support all the things we could imagine here. As such, it's good that defaultTestResultHandler (or your new version of it) only supports the things that are directly needed/supported by bin/jest.js now.

Specifically, it doesn't appear that it's necessary (given what you've built here) to have a class instead of just a module that exports a simple function or two. Instead, how about just a module that exports a printConciseTestResult() and a printDetailedTestResult() function? That way the switching logic that decides which one of those two output formats stays closer to the CLI code, and doesn't wind up bleeding down into other parts of the library.

@johanneslumpe
Copy link
Author

Hey Jeff, not a problem at all. Have been moving until today myself. Still not finished. I will revisit this soon and come up with a better structure. Exporting just the printing functions might work fine. I'll write a follow up post as soon as I've got something!

@johanneslumpe
Copy link
Author

ping @jeffmo

@alexanderjeurissen
Copy link

@jeffmo we need this! is there anything i can do to speed up the process of this getting merged?

@guillaume86
Copy link

I'm also interested in this, detailled results would be nice + it's easy to forget a .only() call and not noticing it with just the suites summary.

@3den
Copy link

3den commented Jan 18, 2015

👍

@tommilimmot
Copy link

Also interested in detailed results!

function _onResultReady(argv, config, result) {
if (argv.detailedResults) {
return defaultTestResultHandler
.printDetailedTestResult(config, result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please indent this lint. There are a bunch of other places where you don't do this when wrapping but that's really tough to read.

@zpao
Copy link
Contributor

zpao commented Jan 21, 2015

I didn't actually look at logic but I think @jeffmo did so I was just the linter. We need a rebase but otherwise I'm inclined to just take this pretty much as is with style fixes.

@johanneslumpe
Copy link
Author

@zpao I'm not sure whether this PR is even usable anymore? In the time that passed since the PR was issued, defaultTestResultHandler.js changed a lot. It was changed into a prototype-based version, which I had earlier, but was asked to change again into functions.

So I am not sure if it really makes sense to fix the identation here now?! Feedback would be appreciated.

@whymarrh
Copy link

If I'm not mistaken, this relates to issue #4 as well as PR #307.

@PhilVargas PhilVargas mentioned this pull request May 14, 2015
@DmitrySoshnikov
Copy link
Contributor

Finally this was implemented (in #370). I guess we can close this PR safely now?

@DmitrySoshnikov
Copy link
Contributor

Closing this one, feel free to open a new issue/PR if this needs something in addition.

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants