jest-extended
jest-extended copied to clipboard
expect: Add matcher `toBeInRange()` to validate if array elements are within the specified range
What
In this PR, I have created a new matcher toBeInRange
.
Why
Recently, I came across a use case where I had to validate if Year
dropdown has options within the specified range. When I checked for assertions, then no such assertion found where I can specify the range and validate or assert.
Notes
Housekeeping
- [x] Unit tests
- [x] Documentation is up to date
- [x] No additional lint warnings
- [x] Typescript definitions are added/updated where relevant
@keeganwitt @mattphillips thoughts?
Codecov Report
Merging #461 (2d7adc5) into main (bbbe109) will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## main #461 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 72 73 +1
Lines 594 601 +7
Branches 151 153 +2
=========================================
+ Hits 594 601 +7
Impacted Files | Coverage Ξ | |
---|---|---|
src/matchers/toBeInRange.js | 100.00% <100.00%> (ΓΈ) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
@keeganwitt @mattphillips thoughts?
@keeganwitt @mattphillips Could you please provide your input?
This seems reasonable to me. We could make the inclusive vs exclusive more flexible, but I don't think that'd add much value, and being inclusive is what I'd kinda expect.
Also add this matcher to the README.
@mattphillips Thank you for the detailed review. I have made the changes. Please review again.
Hello @keeganwitt @mattphillips,
Could you please review this again?
Thanks!
@mattphillips @keeganwitt I have resolved the conflicts. Please have a look again.
Hello @SimenB @keeganwitt @mattphillips
Any update on this?
Sorry, I haven't had a chance to get back to this. I'll take a look this week.
A few more things are needed before this is ready:
- https://github.com/jest-community/jest-extended/blob/main/website/docs/matchers/index.md should be updated to include this new matcher.
- There are two places in index.d.ts that get updated every time a new matcher is added: the
Matchers
interface andExpect
interface. This PR only has the latter.
A few more things are needed before this is ready:
- https://github.com/jest-community/jest-extended/blob/main/website/docs/matchers/index.md should be updated to include this new matcher.
- There are two places in index.d.ts that get updated every time a new matcher is added: the
Matchers
interface andExpect
interface. This PR only has the latter.
Sure will update.
A few more things are needed before this is ready:
- https://github.com/jest-community/jest-extended/blob/main/website/docs/matchers/index.md should be updated to include this new matcher.
- There are two places in index.d.ts that get updated every time a new matcher is added: the
Matchers
interface andExpect
interface. This PR only has the latter.Sure will update.
Sounds good! Thanks for your persistence!
@keeganwitt I have updated now. Please review