-
-
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
Regression in output of an error throw by a -r
module throws (within yargs)
#4316
Comments
sorry got confused. #4311 |
duplicate of #4310 |
a fix will land in v8.0.0 |
@boneskull thanks for looking at this - did look around for other issues but didn't quite make the connection this would be solved by the one you linked to. Btw, this came up when I was trying to port a mocha plugin to the new |
@alexjeffburke Thanks for the kind words. Yes, this was kind of buried (the fix landed as part of something else), so I don't fault you for not being able to find it. |
Prerequisites
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.Description
When a module loaded with
-r
throws in the current version of mocha 7, the call made to yargs.showHelp() after the error is printed (https://github.com/mochajs/mocha/blob/v7.2.0/lib/cli/cli.js#L53) seems to throw with the following stack trace:Having looked into the yargs code at line 240 in yargs/lib/usage.js mentioned above, the problem seems to be that at this point
yargs.parsed
is false, which means the dereference of newAliases returns undefined and thenObject.keys()
wrapped around it throws a null or undefined error.Steps to Reproduce
This error can be reproducued by saving the following in a file called "thrower.js":
and mocha executed as follows:
Expected behavior:
The error thrown by the require hook is printed to the console.
Actual behavior:
Before the error can be thrown an internal error is created from within yargs.
Reproduces how often: [What percentage of the time does it reproduce?]
This is consistently reproducible.
Versions
Mocha version
7.2.0
The text was updated successfully, but these errors were encountered: