Lexicographic string comparison
See original GitHub issue🚀 Feature Proposal
JavaScript supports comparing strings: '2018-01-01' < '2019-01-01'
. Jest should pass that through.
Motivation
I want to be able to easily compare ISO8601 dates.
Example
expect(date).toBeGreaterThan('2020-06-01')
expect(doc.updatedAt).toBeGreaterThan(doc.createdAt);
Pitch
-
Why does this feature belong in the Jest core platform?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Lexicographic Order
To determine which string comes first, compare corresponding characters of the two strings from left to right. The first character where the two...
Read more >How To Compare Two Strings Lexicographically In Java
Java compareTo() method Compares two strings lexicographically, The comparison is based on the Unicode value of each character in the strings.
Read more >String Comparison in Java - Stack Overflow
The Java String class provides the .compareTo () method in order to lexicographically compare Strings. It is used like this "apple".compareTo ("banana") ....
Read more >Compare two strings lexicographically in Java. - Tutorialspoint
Compare two strings lexicographically in Java. - The compareTo() method of the String class. This method compares two Strings ...
Read more >Java exercises: Compare two strings lexicographically
Write a Java program to compare two strings lexicographically. Two strings are lexicographically equal if they are the same length and contain ...
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 think this would be better as a separate matcher to avoid confusion around why assertions with strings pass and to ensure users are explicit about what type they expect in the matcher. And because of its rare use cases, I would say it’s a better fit for jest-extended.
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.