jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
43.84k stars 6.39k forks source link

[Feature]: Expose all matchers as asymmetric matchers #15102

Open lcswillems opened 4 weeks ago

lcswillems commented 4 weeks ago

🚀 Feature Proposal

This is a copy of the issue https://github.com/jestjs/jest/issues/14700 with slight modifications.

Making all matchers available as asymmetric matchers.

Motivation

How to check if the value of a property of an object is greater than 10? There is no easy way to do in Jest.

Example

expect({ value: 11 }).toMatchObject({ value: expect.toBeGreaterThan(10) });

Pitch

This shouldn't require an additional matcher library since the goal is not to add any new matchers. It's simply a case of removing an unnecessary limitation on existing matchers.