Extended matcher does not work properly (doc pasted example)
See original GitHub issueCustom made matcher from documenation toBeWithinRange
is working in scenarion like this
expect(100).toBeWithinRange(90, 110);
But throws an error in scenario like that
expect({ apples: 6, bananas: 3 }).toEqual({ apples: expect.toBeWithinRange(1, 10), bananas: expect.not.toBeWithinRange(11, 20)});
Error:
expect.toBeWithinRange is not a function
🐛 Bug Report
To Reproduce
Steps to reproduce the behavior:
Visit this codesandbox, uncomment not working part of code then run tests.
If codesandbox does not work for you, try to run this example from docs
Expected behavior
Link to repl or repo (highly encouraged)
envinfo
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Going too far with Jest Custom Matchers in TypeScript
I needed a Jest custom matcher a few days ago, and I couldn't find any article I could copy-paste it from. The docs...
Read more >Most common example of Jest custom matcher in TypeScript ...
I am using Jest v27.4.7 and have looked at numerous examples of how to implement a custom matcher in Jest with TypeScript.
Read more >Expect - Jest
Instead, you will use expect along with a "matcher" function to assert something about a value. It's easier to understand this with an...
Read more >Some characters missing or cut off when displayed on screen ...
When you view your document in Microsoft Word, some characters may be missing, or the top (or bottom) of some characters may be...
Read more >Expect · Jest
Matchers should return an object with two keys. pass indicates whether there was a match or not, and message provides a function with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe this is an issue with codesandbox’s version of Jest. This is because both when I copy the code from the docs into a new Jest project, and when I export the codesandbox project to zip, it works. Please report the issue to codesandbox instead.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.