Closed thekevinscott closed 9 years ago
Good find. Maybe during this try/catch while we attempt to load the reporter, we can capture stderr
and stdout
.
Tried temporarily capturing console.warn which works, but what do you think about trying to require the reporter first (and catching the error in cli.js
)? Something like:
I'll put comments in that PR. Pro tip: you can attach a pull request to an existing issue via the github cli hub
.
Oh nice, I did not know! Thanks for that.
Closed since #59 got merged.
I tried this just as you described and with the dot reporter everything works fine. But there's a problem with 3rd party reporters for mocha such as mocha-teamcity-reporter.
Do you plan to solve that stuff or is this beyond the scope of the project? And if there should be a solution, how can i assist? ;)
Do you plan to solve that stuff or is this beyond the scope of the project?
The core issue is that the reporter is not running in node.js nor the browser, but in phantomjs. That environment supports CommonA/JS require
syntax, but doesn't use npm paths to load and is not node so process
is not there, streams, etc. fs
is very different for example. So writting a generic node.js api to phantomjs api is very beyond the scope of the project and not reasonably achievable anyway IMO.
Oddly though once people become aware of it, it usually takes very little effort to support mocha-casperjs
. looking at the teamcity reporter:
if (typeof window === 'undefined') {
// running in Node
Base = require('mocha').reporters.Base;
log = console.log;
} else {
// running in mocha-phantomjs
Base = require('./base');
log = function(msg) { process.stdout.write(msg + "\n"); };
}
should go to this:
if (typeof Mocha !== 'undefined') {
// running in mocha-phantomjs or mocha-casperjs that use the pre-compiled version of mocha
Base = Mocha.reporters.Base;
log = function(msg) { process.stdout.write(msg + "\n"); };
} else {
// running in Node
Base = require('mocha').reporters.Base;
log = console.log;
}
So try that and submit a PR to them?
This is pretty minor, but I just bumped my version of Mocha to 2.2.5 and am receiving some warnings when trying to load a third party reporter.
Here's a repo showing what I mean.
Calling Mocha directly produces:
Calling Mocha-Casperjs produces:
The reporter is still included perfectly fine, but it looks like this commit adds in some
console.warn
statements. Not sure if there's a way around these?