-
-
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
--reporter-option(s) flags in .opts files are ignored when running with _mocha #3826
Comments
I don't know much about
I guess this part shows the content after Mocha finished its option parsing, right? So the option file was found and the flags are read successfully.
You are using
Did your way of using |
I made some short tests with:
It worked correctly both ways, via CLI and also via I tested against our current master, maybe the problem is already fixed, will need more testing. BTW: I tested with node.exe mocha, not via npm / npx. Maybe you could try also via node.exe |
Thanks for looking into this! Thanks to your last suggestion, I figured out what the actual issue is! It turns out that my project was using The error and repro steps I reported are wrong. I had copypasted the command with an opts file from my package.json, but wrote the command with flags from scratch, and I didn't notice that the former was using I'm not sure if this is even a bug now, since the |
Was surprised at your reported issue, as running XUnit reporter with same arguments is one of our integration tests.
Simplistic explanation why there are two binaries is that "/bin/mocha" relaunches itself as "/bin/_mocha" with Node cmdline options applied -- if you're not using V8 options or debugger, there's nothing gained. Currently, there's a PR in work to not bother relaunching if no Node flags exist, so "/bin/mocha" is the binary that should be used. That said, your setup should have worked against "/bin/_mocha". Could you correct whatever is incorrect in issue description above so we can look into this further? Exact macOS version? P.S. Ditch global "mocha" installation. Use "bash" alias if direct launching of local install desired. $ cd /path/to/project
$ alias mocha=$(pwd)/node_modules/.bin/mocha
$ alias _mocha=$(pwd)/node_modules/.bin/_mocha |
In my setup it does not work with "/bin/_mocha" and IMO this is ok, so no bug. Just compare the call in /bin/_mocha with PR #3827 } else {
require('../lib/cli/cli').main(unparse(mochaArgs, {alias: aliases}));
} |
I corrected the description in case other people run into this. I'm inclined to agree that this isn't a bug, but if other people are using |
Just to make sure: "/bin/_mocha" does work with CLI options, but not with config/option files. So I'm not sure wether your corrected description is correct now. I don't know wether this behavior has changed since v5.2. I remove the label "unconfirmed-bug", please close this issue if you don't have any further question. |
Hold on. The question at large is whether this was intentional. IMO "/bin/_mocha" should definitely work, unless @boneskull meant to do so; nothing was mentioned in the release notes for Mocha-6.0. |
Some of my conclusions were incorrect. 😎 Unfortunately I have not yet succeeded in debugging a child process (
The value of the fourth one is certainly wrong and we also don't use camelcase options. |
The bug is caused by this line in "cli/cli.js": When run with When run with |
I don't know if this is the same, I am not able to get |
|
EDIT 2019-03-14: I had originally misdiagnosed the issue, and thought it was related to .opt files. The actual issue is with the binary used.
EDIT 2019-03-15: The actual issue is with both .opt files and the mocha binary.
Prerequisites
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.Description
When I upgrade to the latest version of mocha, my settings
--reporter-option
and--reporter-options
flags are not being respected by the built-in xunit reporter, or by custom reporters. After some debugging, it looks like the--reporter-option
flag is ignored when_mocha
command to run tests.The
--reporter-option
flag works when I pass it tomocha
or_mocha
directly, and options files work withmocha
. It's only when I use options files and the_mocha
command together that the flag is ignored.The
--reporter-options
flag has identical behavior in all cases.Steps to Reproduce
Expected behavior:
Results are saved in "spec/reports/unit-test-report.xml"
Actual behavior:
Results are printed on the console.
Reproduces how often:
Always
Versions
mocha --version
andnode node_modules/.bin/mocha --version
: 6.0.2node --version
: v8.12.0Additional Information
The text was updated successfully, but these errors were encountered: