最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论