This is my folder structure
src/
a.js
b.js
test/
a.spec.js
b.spec.js
and I've tried running
~/.../src $ mocha
~/.../src $ mocha test
~/.../src $ mocha test/
~/.../src $ mocha ./test/
~/.../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.
According to it, tests are run synchronously. This only shows that ordered code is run in order. That doesn't happen by accident.
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.
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.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With