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.

Better reporting for string differences

See original GitHub issue

🚀 Feature Proposal

When using toEqual to compare strings (or other iterable structures), when there is a difference between the strings, indicate where the first difference occurred and/or give additional details about the difference.

Motivation

While testing the output of a currency formatting function, I was bamboozled by the following output: image

As it turns out, the spaces in the strings are different (breaking x20 vs non-breaking space xA0).

Example

Expected value to equal:
"1 234,57 $"
Received:
"1 234,57 $"
First difference occurred at index 1 : " " does not equal " "

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pedrottimarkcommented, May 27, 2019

Although the pull request highlights the changed substrings, they still look the same.

A possible future improvement is heuristic to display other invisible characters in addition to:

  • U+21B5 ↵ for deleted or inserted line break
  • U+00B7 · for space at end of line
2reactions
novemberborncommented, Oct 15, 2018

@SimenB not a heck of a lot, no. The basic idea would be to use control pictures where appropriate, and \u sequences for everything else. That may be annoying with dashes though.

Would love to have a shareable library for this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compare String Values | ReportsNow DAS User Guide
To compare two string values, add the String Compare calculation: Using the CTRL key, select two Column Headers. Right-click either column header and...
Read more >
3 Ways to Compare Strings in C++ - DigitalOcean
In this article, you will learn methods to compare strings in C++. Strings in C++ can be compared using one of the following...
Read more >
Approximate String Comparison and its Effect - Washington
is 2 percent. The results generally show that the different string comparators improve matching efficacy. In all of the best situations, error levels...
Read more >
Compare two strings value in rdl file - Stack Overflow
Please help. NPServedasperPolicy and NPServed parameter values are coming from reports values. public function getNoticePeriodStatus (byval ...
Read more >
Approximate String Comparison and its Effect on an Advanced ...
This paper describes string comparators and their effect in a production matching system. Because many lists have typographical errors in more ...
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