jest
jest copied to clipboard
[Bug]: diffStrings breaks surrogate pairs
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
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.
Not stale
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.
Not stale
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.
Not stale
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.
Not stale
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.
Not stale
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.
Not stale. PR in https://github.com/jestjs/jest/pull/15812
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.
Not stale