Skip to content

Latest commit

 

History

History
36 lines (20 loc) · 1 KB

no-assert-logical-expression.md

File metadata and controls

36 lines (20 loc) · 1 KB

Disallow binary logical expressions in assert arguments (qunit/no-assert-logical-expression)

💼 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.