Skip to content

Latest commit

 

History

History
53 lines (34 loc) · 1.48 KB

no-nested-tests.md

File metadata and controls

53 lines (34 loc) · 1.48 KB

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

✅ The "extends": "plugin:qunit/recommended" property in a configuration file enables this rule.

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