Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are nested mocha test suites not run when mocha is run with --recursive flag

Following mocha nested test suite structure is run as expected with: mocha --timeout 25000 test.js

describe('test suite 1', function() {
  it('unit test 1', (done) => {

    describe('test suite 2', function() {
      it('unit test 2') {

        describe('test suite 3', function() {
          it('unit test 3') {

I don't see why this isn't the case when test are run with: mocha --recursive --timeout 25000

Looking in debug log I can clearly see that it 2 and it 3 are not run. I have to use mocha --recursive --timeout 25000 as I have more test suite files.

like image 492
Matko Avatar asked Oct 29 '25 08:10

Matko


1 Answers

The structure you are showing in your question is not supported by Mocha. To cover the various cases:

  • describe inside describe? Fine.

  • it inside describe? Fine.

  • describe inside it? Mocha does not support this. The results are undefined. If you get the results you expect, that's due to luck.

  • it inside it? Again, not supported by Mocha. The results are undefined.

like image 54
Louis Avatar answered Nov 01 '25 14:11

Louis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!