Mocha: BDD and TDD files can be mixed when using "--ui tdd" but not when using "--ui bdd"

Created on 21 Jun 2018  路  6Comments  路  Source: mochajs/mocha

As far as I understand you are not supposed to mix testing style i.e. have some files using BDD and some using TDD.
I mean, then what would the point be to specify the style with the ui flag if it would work automatically anyway?
However, if you do use "mocha --ui tdd" then indeed it seems to work with bdd files too.
But when you try with the opposite ("mocha --ui bdd") it does not work with tdd files, which does not make sense to me.

Example with two files (using mocha 5.2.0):

test/test_bdd.js

var assert = require('assert');
describe('Array', function() {
  describe('#indexOf()', function() {
    it('should return -1 when the value is not present', function() {
        assert.equal([1,2,3].indexOf(4), -1);
    });
  });
});

test/test_tdd.js

var assert = require('assert');
suite('Array', function() {
  suite('#indexOf()', function() {
    test('should return -1 when not present', function() {
      assert.equal(-1, [1,2,3].indexOf(4));
    });
  });
});

mocha --ui tdd
Result:
2 passing tests

mocha --ui bdd
Result:
ReferenceError: suite is not defined

confirmed-bug good-first-issue help wanted

Most helpful comment

bdd ui always is called. So, bdd ui called twice if you specified --ui bdd. bdd and tdd uis called if you specified --ui tdd.

I should look deeply to check if it is a bug or an intention.

All 6 comments

bdd ui always is called. So, bdd ui called twice if you specified --ui bdd. bdd and tdd uis called if you specified --ui tdd.

I should look deeply to check if it is a bug or an intention.

@outsideris I do not believe this behavior is intentional,

CC @mochajs/core

Yes, bdd is always set up afaik. Ideally if you specify one, that's the only one that works. If that bothers someone, feel free to PR. Otherwise, better things to focus time on than the purity of the flag, I'd say!

I'd say it's more of a "didn't care" than a "bug".

@dasilvacontin thanks, I agree its a trivial side case.

This has been fixed via #3556.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seelikes picture seelikes  路  3Comments

niftylettuce picture niftylettuce  路  3Comments

adamhooper picture adamhooper  路  3Comments

danielserrao picture danielserrao  路  3Comments

delta62 picture delta62  路  3Comments