-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
area: node.jscommand-line-or-Node.js-specificcommand-line-or-Node.js-specificarea: usabilityconcerning user experience or interfaceconcerning user experience or interfacetype: buga defect, confirmed by a maintainera defect, confirmed by a maintainer
Milestone
Description
Description
Mocha's cmdline argument processing is not working as it should. Defaults are being applied prior to determining if the user-provided cmdline arguments were valid.
Steps to Reproduce
Checked with various non-boolean cmdline options that should require arguments, such as:
- --timeout
- --slow
- --require
- --global
- --ui
Expected behavior: [What you expect to happen]
When using an argument-requiring cmdline option and none provided, an error should occur.
Usage (a la --help), followed by error message, should be output to stderr.
This works correctly when using "bin/_mocha" directly...
$ DEBUG="*" bin/_mocha --ui >/dev/null
mocha:cli:cli entered main with raw args [ '--ui' ] +0ms
mocha:cli:config found config at /var/tmp/mocha/.mocharc.yml +0ms
mocha:cli:options no config found in /var/tmp/mocha/package.json +0ms
mocha:cli:options No mocha.opts found at ./test/mocha.opts +1ms
mocha:cli:cli YError: Not enough arguments following: ui
[SNIP stacktrace]
[SNIP usage and error]Actual behavior: [What actually happens]
This fails when using "bin/mocha"...
$ cd </path/to/mocha/repo/clone> # :NOTE: Don't care about tests themselves...
$ bin/mocha --ui
0 passing (1ms)$ DEBUG="*" bin/mocha --ui
mocha:cli:config found config at /var/tmp/mocha/.mocharc.yml +0ms
mocha:cli:options no config found in /var/tmp/mocha/package.json +0ms
mocha:cli:options No mocha.opts found at ./test/mocha.opts +0ms
mocha:cli loaded opts { _: [],
config: false,
package: false,
opts: false,
require: [ 'test/setup' ],
r: [ 'test/setup' ],
ui: 'bdd',
u: 'bdd',
global: [ 'okGlobalA', 'okGlobalB', 'okGlobalC', 'callback*' ],
globals: [ 'okGlobalA', 'okGlobalB', 'okGlobalC', 'callback*' ],
timeout: 200,
t: 200,
timeouts: 200,
diff: true,
extension: [ 'js' ],
'watch-extensions': [ 'js' ],
reporter: 'spec',
R: 'spec',
slow: 75,
s: 75 } +0ms
mocha:cli exec /usr/local/bin/node w/ args: [ '/var/tmp/mocha/bin/_mocha',
'--no-config',
'--no-package',
'--no-opts',
'--require',
'test/setup',
'--ui',
'bdd',
'--global',
'okGlobalA',
'--global',
'okGlobalB',
'--global',
'okGlobalC',
'--global',
'callback*',
'--timeout',
'200',
'--diff',
'--extension',
'js',
'--reporter',
'spec',
'--slow',
'75' ] +5ms
mocha:cli:cli entered main with raw args [ '--no-config',
'--no-package',
'--no-opts',
'--require',
'test/setup',
'--ui',
'bdd',
'--global',
'okGlobalA',
'--global',
'okGlobalB',
'--global',
'okGlobalC',
'--global',
'callback*',
'--timeout',
'200',
'--diff',
'--extension',
'js',
'--reporter',
'spec',
'--slow',
'75' ] +0ms
mocha:cli:run:helpers resolved test/setup to /var/tmp/mocha/test/setup +0ms
mocha:cli:run:helpers loaded require "test/setup" +198ms
mocha:cli:run post-yargs config { _: [],
diff: true,
config: false,
package: false,
opts: false,
require: [ 'test/setup' ],
r: [ 'test/setup' ],
ui: 'bdd',
u: 'bdd',
global: [ 'okGlobalA', 'okGlobalB', 'okGlobalC', 'callback*' ],
globals: [ 'okGlobalA', 'okGlobalB', 'okGlobalC', 'callback*' ],
timeout: 200,
t: 200,
timeouts: 200,
extension: [ 'js' ],
'watch-extensions': [ 'js' ],
watchExtensions: [ 'js' ],
reporter: 'spec',
R: 'spec',
slow: 75,
s: 75,
spec: [ 'test/' ],
'$0': 'mocha' } +0ms
mocha:suite bail undefined +0ms
mocha:suite slow 75 +0ms
mocha:suite timeout 200 +0ms
mocha:cli:run:helpers files (in order): [ '/var/tmp/mocha/test/assertions.js',
'/var/tmp/mocha/test/setup.js' ] +4ms
mocha:cli:run running tests with files [ '/var/tmp/mocha/test/assertions.js',
'/var/tmp/mocha/test/setup.js' ] +3ms
mocha:runner grep /.*/ +0ms
mocha:runner globals ["DTRACE_NET_SERVER_CONNECTION","DTRACE_NET_STREAM_END","DTRACE_HTTP_SERVER_REQUEST","DTRACE_HTTP_SERVER_RESPONSE","DTRACE_HTTP_CLIENT_REQUEST","DTRACE_HTTP_CLIENT_RESPONSE","global","process","Buffer","clearImmediate","clearInterval","clearTimeout","setImmediate","setInterval","setTimeout","__core-js_shared__","expect","before","after","beforeEach","afterEach","run","context","describe","xcontext","xdescribe","specify","it","xspecify","xit","XMLHttpRequest","Date"] +0ms
mocha:runner globals ["okGlobalA","okGlobalB","okGlobalC","callback*","okGlobalA","okGlobalB","okGlobalC","callback*"] +1ms
mocha:runner start +0ms
mocha:runner run suite +0ms
mocha:runner finished running +0ms
0 passing (0ms)
mocha:runner end +2msVersions
- The output of
mocha --version: 6.0.0-1 - The output of
node --version: v10.15.0 - The version and architecture of your operating system: macOS 10.13.6
- Your shell (bash, zsh, PowerShell, cmd, etc.): bash
Metadata
Metadata
Assignees
Labels
area: node.jscommand-line-or-Node.js-specificcommand-line-or-Node.js-specificarea: usabilityconcerning user experience or interfaceconcerning user experience or interfacetype: buga defect, confirmed by a maintainera defect, confirmed by a maintainer