question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extended matcher does not work properly (doc pasted example)

See original GitHub issue

Custom 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:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
jeysalcommented, May 30, 2020

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.

0reactions
github-actions[bot]commented, May 11, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found