admin管理员组

文章数量:1421492

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?

Share Improve this question asked May 16, 2013 at 14:02 Matt ZukowskiMatt Zukowski 4,5414 gold badges39 silver badges40 bronze badges 1
  • 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
Add a ment  | 

3 Answers 3

Reset to default 10

Add --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';

本文标签: javascriptMaking mocha quotuse strictquot when running in nodeStack Overflow