-
Notifications
You must be signed in to change notification settings - Fork 22
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
Specify reporterOptions in .mocharc.js #60
Comments
Maybe I am missing something, but I tried every possible combination without success :( |
Fixed in #32 const mocha = new Mocha({
reporter: "mocha-multi-reporters",
reporterOptions: {
"reporterEnabled": 'spec, mocha-junit-reporter',
"mochaJunitReporterReporterOptions": {
"mochaFile": "junit-custom.xml",
"includePending": true,
"outputs": true
}
}
}); |
That doesn't work @dragancla Because we are here about meaning "use strict";
module.exports = {
reporter: "mocha-multi-reporters",
reporterOptions: {
"reporterEnabled": 'spec, mocha-junit-reporter',
"mochaJunitReporterReporterOptions": {
"mochaFile": "junit-custom.xml",
"includePending": true,
"outputs": true
}
}
} |
While I understand this is a different issue, is anyone able to get |
I think I was able to fix this: module.exports = {
reporter: 'mocha-multi-reporters',
'reporter-options': 'configFile=reporter.config.json'
} You still have to have a separate file, unfortunately, but it looks like using quotes around https://mochajs.org/#configuration-format I was looking at their examples: https://github.com/mochajs/mocha/blob/master/example/config/.mocharc.js and noticed that two-worded flags were kept hyphenated with quotes and not camel-cased. |
👋. Using the examples above (in the I'm not sure if this has been fully implemented yet based on this comment... but it always defaults to |
I ran into this issue as well, though I'm using the JSON format for mocharc instead of JS. I believe it would be a similar issue. What looks like is happening if you do not specify configFile in the reporterOptions is that it first loads the default file here: This file is defaulting to spec and xunit, which is the behavior that rob4629 saw: But then it's supposed to find custom options to overlay over the defaults, which can come from mocharc.js, here: However, if I define something like this in mocharc.js: { The call on 171 fails to get any options. If you print out the contents of options, which is the input to line 171, you will see this piece: ... So the call to get() returns undefined, even though there are options under reporterOptions. This looks to be the reason you cannot currently specify reporter options directly in mocharc, they cannot be loaded correctly by the call on line 171. |
A working solution: tell {
"reporter": "mocha-multi-reporters",
"reporterEnabled": "spec, mocha-junit-reporter",
"reporterOptions": "configFile=.mocharc.json",
"mochaJunitReporterReporterOptions": {
"mochaFile": "./junit.xml",
"includePending": true,
"outputs": true
}
} |
@mielp Didn't this solution cause you problems with parallel mode? |
Expected behavior
I would like to specify reporterOptions inside
.mocharc.js
file like this:Actual behavior
When specified in
.mocarc.js
,reportIOptions
are being ignored and I have to still use external file:Information about the Issue
I am using following packages:
The text was updated successfully, but these errors were encountered: