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.

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jeysalcommented, Jun 4, 2020

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.

0reactions
github-actions[bot]commented, Nov 14, 2022

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

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 >

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