Skip to content

Better reporting for string differences #6881

@mlevesquedion

Description

@mlevesquedion

🚀 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 " "

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions