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.

String Comparison Incorrect

See original GitHub issue

🐛 Bug Report

When comparing the string "1.234,56 CHF" to "1.234,56 CHF" (apparently identical) Jest is coming up with not equal. It boils down to JavaScript being weird in that "1.234,56 CHF" == String("1.234,56 CHF") is apparently false.

jasmineUtils.js: image

image

image

envinfo

  System:
    OS: Windows 10 10.0.16299
    CPU: (4) x64 Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
  Binaries:
    Node: 13.2.0 - C:\prg\nodejs\node.EXE
    Yarn: 1.5.1 - C:\prg\yarn\bin\yarn.CMD
    npm: 6.13.1 - C:\prg\nodejs\npm.CMD
  npmPackages:
    jest: ^24.9.0 => 24.9.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
pedrottimarkcommented, Dec 6, 2019

@jeysal @cawoodm What do you think about this quick and dirty prototype using ES2018 RegExp Unicode property escapes (in Node 8 with --harmony_regexp_property flag and in Node 10 without flag) to detect replacement of adjacent characters which have General_Category=Space_Separator and format the code point (if either or both are not space).

There are probably some more low-hanging fruit like delete or insert of zero-width characters.

Baseline at left and imagined relevant comparison at right:

2019-12-06 space separator
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

CWE-597: Use of Wrong Operator in String Comparison (4.9)
The product uses the wrong operator when comparing a string, such as using "==" when the .equals() method should be used instead. +...
Read more >
java - Comparing two identical strings with == returns false
In your code, you are comparing an Object with a String literal (also an object), which is not the same as comparing the...
Read more >
Incorrect string equality operator - AWS Documentation
Use equals() , not == , when checking if two strings are equal. This ensures strings that have the same value are treated...
Read more >
Comparing Strings in Java - Baeldung
The method returns true if two Strings are equal by first comparing them using their address i.e “==”. Consequently, if both arguments are...
Read more >
String.Compare Method (System) - Microsoft Learn
The comparison terminates when an inequality is discovered or both substrings have been compared. However, if the two strings compare equal to the...
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