expect(null).to.be.within(0,10) does not fail assertion
See original GitHub issueExpected behavior:
expect(null).to.be.within(0,1)
should return false for any numbers a and b.
Actual behavior:
expect(null).to.be.within(0,1)
returns true. Sam for other falsey values, I assume, and similar problem with true.
Proposed fix: Within should check that the value is a number and reject if it isn’t before comparing the range here.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:18 (14 by maintainers)
Top Results From Across the Web
How to assert not null? - javascript - Stack Overflow
It's often best to assert that the one expected output was produced, rather than asserting that one of countless unexpected outputs wasn't produced....
Read more >Expect - Jest
The expect function is used every time you want to test a value. You will rarely call expect by itself. Instead, you will...
Read more >API Reference - Chai Assertion Library
Chai is a BDD / TDD assertion library for [node](http://nodejs.org) and the browser that can be delightfully paired with any javascript testing framework....
Read more >What is the assert.isNotNull() method in Chai.js? - Educative.io
If the value is null, then nothing is returned, meaning the test was successful. However, if an error is thrown, then it was...
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
@vieiralucas Absolutely. In fact, it’s on Chai’s roadmap for 7.x.x to claim all of the world’s Lucases as contributors. With your contribution, we’ll be up to two! 😄
If you have any questions, doesn’t hesitate to ask. Also, please keep the PR in scope of what was agreed upon earlier in the thread (i.e., numbers-only).
@vieiralucas It’s totally fine with me, and I don’ think anyone else would mind, so go ahead!