Skip to content

Latest commit

 

History

History
27 lines (15 loc) · 681 Bytes

prefer-to-contain.md

File metadata and controls

27 lines (15 loc) · 681 Bytes

Enforce using toContain() (vitest/prefer-to-contain)

⚠️ This rule warns in the 🌐 all config.

🔧 This rule is automatically fixable by the --fix CLI option.

This rule triggers a warning if toBe(), toEqual() or toStrickEqual() is used to assert object inclusion in an array.

The following patterns are considered warnings:

expect(a.includes(b)).toBe(true);
expect(a.includes(b)).toEqual(true);
expect(a.includes(b)).toStrictEqual(true);

The following patterns are not considered warnings:

expect(a).toContain(b);