Is there a way to make Mocha run tests in strict mode when running on node?
Normally you can enable this in node by running node --use_strict
. Is there a way to do the same thing for mocha
?
Is there a way to make Mocha run tests in strict mode when running on node?
Normally you can enable this in node by running node --use_strict
. Is there a way to do the same thing for mocha
?
-
The accepted answer is clearly wrong (it doesn't do the same thing as
node --use_strict
. Please consider accepting the other (upvoted) one. – Tad Lispy Commented Mar 24, 2017 at 13:06
3 Answers
Reset to default 10Add --use_strict
to the mocha mand.
So your mand might look like this :
mocha ./test --recursive --use_strict
There is no way to pass --use_strict into mocha and this was done in purpose. Read the discussion for details.
If you really want this behaviour you could fork mocha's sources or load this npm module as a first thing in your tests.
I would just start test scripts with
'use strict';