Mocha: Mocha doesn't respect command line `--timeout 10000` setting

Created on 12 Jun 2017  路  2Comments  路  Source: mochajs/mocha

Like title indicated, I use mocha with istanbul, previously(end of last year) it works totally fine, but don't know since when, mocha start not respecting the global command line --timeout 10000 setting.

"scripts": {
   "test": "./node_modules/istanbul/lib/cli.js cover ./node_modules/.bin/_mocha --check-leaks --timeout 10000 --sort ./test/index.js"
}

Like above, then it will report: Warning: Could not find any test files matching pattern: 10000

"scripts": {
   "test": "./node_modules/istanbul/lib/cli.js cover ./node_modules/.bin/_mocha --check-leaks --timeout=10000 --sort ./test/index.js"
}

Like above, no that warning, but got bunches of error due to the test cases timeout:

Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

it just all goes back to the default 2000ms default setting.

And I updated to the latest release 3.4.2, still exactly same error happens.

@Munter @ScottFreeCode @kunagpal @boneskull pls help to fix.

Most helpful comment

@Inshi Timeout (and other options mentioned above) are related to Mocha, not Istanbul. You'll have to pass them like so:

./node_modules/istanbul/lib/cli.js cover ./node_modules/.bin/_mocha -- --check-leaks --timeout 10000 --sort ./test/index.js

Notice the -- right after the path to the Mocha executable, this lets Istanbul know when to stop processing command line arguments as its own.

All 2 comments

@Inshi Timeout (and other options mentioned above) are related to Mocha, not Istanbul. You'll have to pass them like so:

./node_modules/istanbul/lib/cli.js cover ./node_modules/.bin/_mocha -- --check-leaks --timeout 10000 --sort ./test/index.js

Notice the -- right after the path to the Mocha executable, this lets Istanbul know when to stop processing command line arguments as its own.

@kunagpal verified, it works, thank you very much, just wonder why previously it wasn't like this.

Think will close the issue.

Was this page helpful?
0 / 5 - 0 ratings