-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
String Comparison Incorrect #9239
Comments
You'll need to supply a repro showing how you actually create the strings you are comparing. |
You could try the following: // Format a currency as a localized string
const formatter = new Intl.NumberFormat('de', {
style: 'currency',
currency: 'CHF
});
let o = {
value: formatter.format(1234.56)
};
// Fail
expect(o).toHaveProperty('value', '1.234,56 CHF'); // Nope
// Workaround
expect(o.replace(/\s/, ' ')).toEqual('1.234,56 CHF'); // Yup |
I guess we're running into this. Apparently Intl does not use space (ASCII 32) but non-breaking space (ASCII 160). Sheesh Intl! |
@pedrottimark I think it's good that the character-by-character diff already highlights where the mismatch is here - any ideas/plans on how to improve on diffs invisible to humans in the future? |
@jeysal Thank you for adding a specific example to my mental slow cooker. Because you have such a strong intuition about first impressions in developer experience, here is a question for your imagination: how to present context information like this when instead of |
@cawoodm Thank you for taking the time to report the issue and especially your discovery. This is same issue as #6881 but your follow up comment is more specific about the reason.
|
Bunch of ideas:
|
@jeysal @cawoodm What do you think about this quick and dirty prototype using ES2018 RegExp Unicode property escapes (in Node 8 with 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: |
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. |
🐛 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:

envinfo
The text was updated successfully, but these errors were encountered: