Skip to content

Files

Latest commit

 

History

History
23 lines (17 loc) · 596 Bytes

no-restricted-matchers.md

File metadata and controls

23 lines (17 loc) · 596 Bytes

Pattern: Use of restricted matcher

Issue: -

Description

Some Jest matchers may be restricted to enforce better testing practices or maintain consistency across test suites. Alternative matchers may be suggested based on project requirements.

Examples

Example of incorrect code:

expect(value).toBeFalsy();
await expect(promise).resolves.toBe(true);
expect(mock).not.toHaveBeenCalledWith("param");

Example of correct code:

expect(value).toBe(false);
await expect(promise).rejects.toThrow();
expect(mock).toHaveBeenCalledWith("expectedParam");