Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mocha not running all tests in test dir

This is my folder structure

src/
   a.js
   b.js
   test/
     a.spec.js
     b.spec.js

and I've tried running

  1. ~/.../src $ mocha
  2. ~/.../src $ mocha test
  3. ~/.../src $ mocha test/
  4. ~/.../src $ mocha ./test/
  5. ~/.../src $ mocha ./test/*.js

but non worked... all I get is just one test file running and the rest are ignored.

The docs say that (1) should do the job but well it doesn't.

like image 982
Yoni Levy Avatar asked Jan 07 '16 08:01

Yoni Levy


People also ask

Do Mocha tests run sequentially?

According to it, tests are run synchronously. This only shows that ordered code is run in order. That doesn't happen by accident.

Does Mocha run tests in parallel?

Mocha does not run individual tests in parallel. That means if you hand Mocha a single, lonely test file, it will spawn a single worker process, and that worker process will run the file. If you only have one test file, you'll be penalized for using parallel mode. Don't do that.

How do I specify a test file in Mocha?

The nice way to do this is to add a "test" npm script in package. json that calls mocha with the right arguments. This way your package. json also describes your test structure.


1 Answers

Well... I'm an idiot. I had it.only in one of my files and I forgot it. Removing the .only was the answer. All the test files are running now.

Sorry for that, shame on me...

like image 179
Yoni Levy Avatar answered Oct 16 '22 16:10

Yoni Levy