🔧 This rule is automatically fixable by the
--fix
CLI option.
For expecting a value to be an object, jest-extended
provides the toBeObject
matcher.
This rule triggers a warning if an expect
assertion is found asserting that a
value is an object using one of the following methods:
- Comparing the result of
<value> instanceof Object
to a boolean value, - Calling the
toBeInstanceOf
matcher with theObject
class.
The following patterns are considered warnings:
expect([] instanceof Object).toBe(true);
expect(myValue instanceof Object).toStrictEqual(false);
expect(theResults() instanceof Object).not.toBeFalse();
expect([]).toBeInstanceOf(true);
expect(myValue).resolves.toBeInstanceOf(Object);
expect(theResults()).not.toBeInstanceOf(Object);
The following patterns are not considered warnings:
expect({}).toBeObject();
expect(myValue).not.toBeObject();
expect(queryApi()).resolves.toBeObject();
expect(theResults()).toBeObject();