qunit/no-assert-logical-expression

February 7, 2026 ยท View on GitHub

๐Ÿ“ Disallow binary logical expressions in assert arguments.

๐Ÿ’ผ This rule is enabled in the โœ… recommended config.

Generally, it is not a good idea to use logical expressions as assertion arguments. Logical-and assertions can be broken down into multiple assertions, while logical-or assertions may be indicative of uncertainty or nondeterminism in a test.

Rule Details

The following patterns are considered warnings:


assert.ok(foo && bar);

assert.ok(foo || bar);

The following patterns are not warnings:


// Multiple assertions for logical-and cases
assert.ok(foo);
assert.ok(bar);

// More deterministic test expectation: maybe only foo should be true here
assert.ok(foo);

When Not To Use It

This rule can be safely disabled if you do not care about the quality of test assertions and the determinism of tests.