Skip to content

Latest commit

 

History

History
45 lines (27 loc) · 1.17 KB

require-object-in-propequal.md

File metadata and controls

45 lines (27 loc) · 1.17 KB

Enforce use of objects as expected value in assert.propEqual (qunit/require-object-in-propequal)

💼 This rule is enabled in the ✅ recommended config.

The assert.propEqual assertion is for the strict-equality comparison of own-properties of two objects. If the expected value is a string or other non-object, the assertion result can be unexpected.

For string comparisons, assert.strictEqual should be used. For arrays, assert.deepEqual should be used.

Rule Details

The following patterns are considered warnings:

assert.propEqual(actual, 0);

assert.propEqual(actual, "foo");

assert.propEqual(actual, `foo`);

assert.propEqual(actual, /regex/);

The following patterns are not considered warnings:

assert.propEqual(actual, { foo: "bar" });

assert.propEqual(actual, ["array"]);

// Variables are not checked
assert.propEqual(actual, foo);

When Not to Use It

This rule should be reasonably safe to use in all circumstances.

Further Reading

assert.propEqual