jest icon indicating copy to clipboard operation
jest copied to clipboard

[Bug]: diffStrings breaks surrogate pairs

Open gofr opened this issue 1 year ago • 8 comments

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 avatar Nov 19 '24 11:11 gofr

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Dec 22 '24 12:12 github-actions[bot]

Not stale

gofr avatar Dec 22 '24 12:12 gofr

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jan 21 '25 13:01 github-actions[bot]

Not stale

gofr avatar Feb 11 '25 14:02 gofr

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Mar 13 '25 15:03 github-actions[bot]

Not stale

gofr avatar Apr 01 '25 08:04 gofr

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar May 01 '25 10:05 github-actions[bot]

Not stale

gofr avatar May 20 '25 05:05 gofr

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jun 19 '25 06:06 github-actions[bot]

Not stale

gofr avatar Jul 12 '25 13:07 gofr

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Aug 11 '25 14:08 github-actions[bot]

Not stale. PR in https://github.com/jestjs/jest/pull/15812

gofr avatar Sep 04 '25 10:09 gofr

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Oct 04 '25 12:10 github-actions[bot]

Not stale

gofr avatar Oct 22 '25 09:10 gofr