javascript - Making mocha "use strict" when running in node - Stack Overflow

Is there a way to make Mocha run tests in strict mode when running on node?Normally you can enable this

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745348147a4623659.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信