-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Multiple reporters support (continuation of #930) #1360
Conversation
…ake the same types of arguments as before, plus a list of reporter names as a comma separated string, or a list of constructors. This allows using more than one reporter. - Replaced command line switch --reporter <name> by --reporters <name>,... so that users can pass a comma separated list of reporters on the command line. - The old --reporters command line switch used to list available reporters is now --list-reporters.
… --reporter and --list-reporters is back to --reporters. - Use the "list" arguments parser for --reporter now. - Mocha.reporters does not accept a comma-separated string of reporter names anymore, this is the command line parser's job to parse the --reporter command line switch and provide an array to this function.
Conflicts: bin/_mocha lib/mocha.js
} catch (err) { | ||
throw new Error('reporter "' + program.reporter + '" does not exist'); | ||
} | ||
} |
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.
Hmm, should this come back? Mocha.prototype.reporter
also throws if the reporter isn't found.
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.
Checking if the reporters exist is still necessary. Ignoring those which are not found is not the way to go, since there is a reason why they have been specified.
Looking at this closer ... I think there's a fundamental flaw. Even though, yes, this invokes multiple reporters – they still all go to stdout. e.g. if you specify So, I'm not sure if this patch is useful unless you can additionally specify a target output file per reporter, something like:
... which seems kind of gross. Thoughts? |
ya that's bit gross. what's your need/use case for multiple reporters btw? |
@travisjeffery lcov generation + arbitrary console logger. As it stands if I want this, I need to run my tests 2x. |
@travisjeffery Please consider #1218 as part of pushing this multiple reporter work through. From my standpoint, being able to include the xunit reporter writing to a file and a spec reporter to console would be great, but I agree with @benvinegar that having multiple reporters going to console doesn't seem very useful. |
@travisjeffery We use both json and xunit at the same time. The former for some scripts that generate reports on our unit tests. The latter for integrating with our particular CI system. I was working on a little converter – pretty trivial – but I saw this patch was nearly accepted and thought I should help push it through. |
+1 from me :) |
35c1580
to
64dfc0b
Compare
Is this going in any time soon? |
I would like to have this feature. 👍 |
I'm not sure how possible these are with |
@dasilvacontin That format looks good to me (and certainly better than whatever the hell I suggested above). I'd be glad to move forward with it. |
I really like the colon to define the file path for a given reporter. It would be nice to hear someone else's opinion too. Very excited about landing this PR on |
Okay, just tried merging up with master and noticed that mocha introduced @dasilvacontin – any thoughts on how you'd like multiple reporters to play nicely with e.g. something like:
|
Reporter options currently have the following format:
Since you can set multiple options for each reporter, what about:
I kind of prefer the |
That works for me. I think we should keep the default behavior the same as today though, for backwards compatibility. Meaning, if you don't specify multiple reporters, this should work fine:
That make sense? |
Sure. We could change it in the future, if necessary, or requested. Current |
this looks good to me |
@travisjeffery, glad to hear that. :) |
+1 |
Conflicts: bin/_mocha lib/mocha.js
Picking this back up. |
Conflicts: lib/mocha.js test/reporters/json.js
I think we need to close this one, as I imagine we'd want this in branch |
please create new PR and squash when ready |
👍 |
any progress? mocha v3.0.0 has been released for a while |
would be great to have .. |
+1 |
Literally just used mocha for the first time and one of the first things I noticed was the total absence of this feature (having used multiple test reporters on Rails tests in the past). FFS, guys... |
@pmarreck Please keep your entitled attitude off of this issue tracker. |
guessing the developers of mocha have good reasons for not supporting multiple reporters out the box for anyone else coming to this ticket looking for multiple reports, i found writing a wee simple custom reporter which pulled in multiple reports from mocha really worked for me As I found a lot of old node modules with combo reporters, on the web copy and pasted the reports, which I found a bit dangerous for my liking (would worry about have a old version of the reporters) my ~20 line reporter `let mocha = require('mocha'); exports = module.exports = MultiReporter; function MultiReporter(runner, options) { which you can just reference with
aka for my project (with my project flags)
|
Hey @boneskull 👋 Is doing #1360 (comment) generally considered fine? |
This is a continuation of @misterdjules PR #930 – multiple reporters support.
On top of @misterdjules work, it has:
_reporter
->_reporters
)Mocha.prototype.reporter
interface (vs the pluralreporters
) for API compatibility. IMHO anybody using Mocha directly shouldn't have to change their code to remain compatible.It does not implement Growl as a separate reporter, as was discussed here. I think it could be done as a follow-up patch just fine, but if you'd prefer that was done before accepting then that's cool too.