Title here
Summary here
Mocha gives you the possibility to structure your tests inside of suites using describe, suite or context. This rule aims to prevent writing tests outside test-suites. Example:
describe('something', function () {
it('should work', function () {});
});
it('should not work', function () {});
This rule checks each mocha test function to not be located directly in the global scope.
it('foo');
test('bar');
it.only('foo');
test.skip('bar');
describe('foo', function () {
it('bar');
});
suite('foo', function () {
test('bar');
});
Caution
It is not always possible to statically detect in which scope a mocha test function will be used at runtime. For example, let’s imagine a parameterized test which is generated inside a forEach
callback:
function parameterizedTest(params) {
params.forEach(function (i) {
it('should work with ' + i, function () {});
});
}
parameterizedTest([1,2,3]);
The rule won’t be applied in this case.