Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making mocha "use strict" when running in node

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?

like image 434
Matt Zukowski Avatar asked May 16 '13 14:05

Matt Zukowski


People also ask

How can you set node to always run in strict mode?

Strict mode example js file: const strictMode = require('./modules/strict'); strictMode. preventExtension(); And the following code in my strict.

What is beforeEach in mocha?

The beforeEach method is a feature (hook) in test libraries that you can use to set preconditions for each test. Just like the name suggests, it runs before each test in your test suite. For example, the beforeEach method will run four times in a suite with four tests.

How do I stop mocha testing?

Find out how you can ignore some tests in Mocha You can use the skip() method (on describe() or it() ) to ignore some tests: In case of describe , it will ignore all tests in the describe block (which includes all nested describe and it functions); In case of it , it will ignore the individual test.


1 Answers

Add --use_strict to the mocha command.

So your command might look like this :

mocha ./test --recursive --use_strict
like image 57
Edward Avatar answered Oct 04 '22 15:10

Edward