Skip to content

Latest commit

 

History

History
55 lines (35 loc) · 1.58 KB

no-nested-tests.md

File metadata and controls

55 lines (35 loc) · 1.58 KB

Disallow nested QUnit.test() calls (qunit/no-nested-tests)

💼 This rule is enabled in the ✅ recommended config.

This rule prevents from incorrect usage of Nested Scope. Developer can write nested test instead of nested module by mistake. In this case test will still be executed, but effects may be unexpected.

Rule Details

The following patterns are considered warnings:

QUnit.test('Parent', function () {
    QUnit.test('Child', function () {});
});

test('Parent', function () {
    test('Child', function () {});
});

QUnit.test('ParentTest', function () {
    QUnit.module('ChildModule', function () {
        QUnit.test('ChildTest', function () {});
    });
});

The following patterns are not considered warnings:

QUnit.test('First', function () {});
QUnit.test('Second', function () {});

QUnit.module('ParentModule', function () {
    QUnit.test('Parent', function () {});

    QUnit.module('ChildModule', function () {
        QUnit.test('ChildTest', function () {});
    });
});

When Not to Use It

It should be safe to use this rule. However it may cause false positive when using same namespace test during act or arrange stages.

Further Reading