Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: diffStrings breaks surrogate pairs #15384

Open
gofr opened this issue Nov 19, 2024 · 0 comments
Open

[Bug]: diffStrings breaks surrogate pairs #15384

gofr opened this issue Nov 19, 2024 · 0 comments

Comments

@gofr
Copy link

gofr commented Nov 19, 2024

Version

29.7.0

Steps to reproduce

test('Surrogate pairs', () => {
  expect('😞').toBe('πŸ˜„');
});

Expected behavior

expect(received).toBe(expected) // Object.is equality

Expected: "πŸ˜„"
Received: "😞"

Actual behavior

Both emojis are made up of surrogate pairs. They have the same high surrogate. When the output contains colors, the low surrogate character is highlighted separately from the high surrogate character, injecting ANSI control sequence characters between the two halves of the surrogate pair, resulting in output like this:

expect(received).toBe(expected) // Object.is equality

Expected: "οΏ½οΏ½"
Received: "οΏ½οΏ½"

Additional context

No response

Environment

System:
    OS: Linux 5.15 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.11.1/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 9.11.0 - ~/.local/share/pnpm/pnpm
@gofr gofr changed the title [Bug]: Diff colors break surrogate pairs [Bug]: diffStrings breaks surrogate pairs Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant