Feature request: Assert less/greater than or equal to
See original GitHub issueI was surprised that this doesn’t exist already.
assert.lte(3, 3, '3 is less than or equal to 3');
It might seem like a small shortcut, but things get messy when you’re expecting a number and don’t get one:
console.log(null <= 4); //=> true
console.log(undefined <= 4); //=> false
I currently do something along the lines of:
const lte = actual === max || actual && actual < max;
assert.isTrue(lte, '...');
… but this still isn’t perfect, especially if you want '3' < 4
to be an error (comparing a string and a number).
I propose that lte
/gte
be designed to work strictly with numbers and throw for anything else.
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Making assertions - Assertible
Asserts that the response time of the entire request is less than a specified value, 1 second by default. If the HTTP request...
Read more >Less than or equal (<=) - JavaScript - MDN Web Docs
The less than or equal ( <= ) operator returns true if the left operand is less than or equal to the right...
Read more >Is there a python assert() method which checks between two ...
You can use assertTrue() for that purpose: self.assertTrue(myInt >= 3 and myInt <= 8). Or, using Python's comparison chaining idiom: self.
Read more >Python's assert: Debug and Test Your Code Like a Pro
In this tutorial, you'll learn how to use Python's assert statement to document, debug, and test code in development.
Read more >What are the Different types of Asserts in Postman? - Tools QA
This assert helps us to verify the Response Time of the Request. Below we are verifying that if the Response Time is less...
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
Just discovered that
expect
/should
has this.It would be nice in the docs to include greater/less than so that when searching least and most will pop up