Closed
Description
openedon May 6, 2020
🐛 Bug Report
The TextEncoder.encode
does not seem to yield a valid U8a, or rather, it cannot be compared. When the output from this is passed into a function expecting a Uint8Array
it does indeed fail.
To Reproduce
This is a failing test -
it('encodes string as Uint8array', (): void => {
expect(
new TextEncoder().encode('Привет, мир!')
).toEqual(
new Uint8Array([208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130, 44, 32, 208, 188, 208, 184, 209, 128, 33])
);
});
The output does not match, rather it fails with -
expect(received).toEqual(expected) // deep equality
- Expected - 23
+ Received + 23
- Uint8Array [
- 208,
- 159,
- 209,
- 128,
- 208,
- 184,
- 208,
- 178,
- 208,
- 181,
- 209,
- 130,
- 44,
- 32,
- 208,
- 188,
- 208,
- 184,
- 209,
- 128,
- 33,
- ]
+ Uint8Array {
+ "0": 208,
+ "1": 159,
+ "10": 209,
+ "11": 130,
+ "12": 44,
+ "13": 32,
+ "14": 208,
+ "15": 188,
+ "16": 208,
+ "17": 184,
+ "18": 209,
+ "19": 128,
+ "2": 209,
+ "20": 33,
+ "3": 128,
+ "4": 208,
+ "5": 184,
+ "6": 208,
+ "7": 178,
+ "8": 208,
+ "9": 181,
+ }
Expected behavior
It was still working on the 25.4.x version before I updated.
Link to repl or repo (highly encouraged)
Failing test included above.
envinfo
System:
OS: macOS 10.15.2
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 13.8.0 - /usr/local/bin/node
Yarn: 2.0.0-rc.30 - /usr/local/bin/yarn
npm: 6.13.7 - /usr/local/bin/npm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment