-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
area: node.jscommand-line-or-Node.js-specificcommand-line-or-Node.js-specificinvalidnot something we need to work on, such as a non-reproducing issue or an external root causenot something we need to work on, such as a non-reproducing issue or an external root causestatus: wontfixtypically a feature which won't be added, or a "bug" which is actually intended behaviortypically a feature which won't be added, or a "bug" which is actually intended behavior
Description
Prerequisites
- Checked that your issue hasn't already been filed by cross-referencing issues with the
faq
label - Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
- 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
- Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with:
node node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.
Description
Running mocha by require it with overriden process.argv will fail if args is not strings. It is hacky way but it allow to use multiple different runners by the same wrapper script, and it worked for mocha2 and mocha4. In mocha 6.0.2 this ends with error.
Steps to Reproduce
const fs = require('fs');
const mocha_file = fs.realpathSync('./node_modules/mocha/bin/_mocha')
process.argv = [process.argv[0], mocha_file, '-t', 20000]
require(mocha_file)
Expected behavior: consume option of number type also
Actual behavior:
/home/anthony/node_modules/mocha/lib/cli/options.js:87
const pair = arg.split('=');
^
TypeError: arg.split is not a function
at nodeArgs.reduce (/home/anthony/node_modules/mocha/lib/cli/options.js:87:25)
at Array.reduce (<anonymous>)
at parse (/home/anthony/node_modules/mocha/lib/cli/options.js:85:67)
at loadOptions (/home/anthony/node_modules/mocha/lib/cli/options.js:288:14)
at Object.exports.main (/home/anthony/node_modules/mocha/lib/cli/cli.js:62:18)
at Object.<anonymous> (/home/anthony/node_modules/mocha/bin/_mocha:10:23)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/home/anthony/test_mocha.js:5:1)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
But fixing it in-place (arg.toString().split('=')
) will not work because of yargs-parser similar issue.
Reproduces how often: always
Versions
- The output of
mocha --version
andnode node_modules/.bin/mocha --version
: 6.0.2 - The output of
node --version
: v.10.15.3
Additional Information
Metadata
Metadata
Assignees
Labels
area: node.jscommand-line-or-Node.js-specificcommand-line-or-Node.js-specificinvalidnot something we need to work on, such as a non-reproducing issue or an external root causenot something we need to work on, such as a non-reproducing issue or an external root causestatus: wontfixtypically a feature which won't be added, or a "bug" which is actually intended behaviortypically a feature which won't be added, or a "bug" which is actually intended behavior