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
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.
Most helpful comment
bddui always is called. So,bddui called twice if you specified--ui bdd.bddandtdduis called if you specified--ui tdd.I should look deeply to check if it is a bug or an intention.