vitest-dev / vitest-dev/vitest

0.34.3 doens't work with `Uint8Array` and `TextEncoder`

Open
#4,043 26 comments 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p2-edge-case
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

The test works in 0.34.2, but doesn't work in 0.34.3

Reproduction
test('toEqual', () => {
  expect([1]).toEqual([1]); // OK
  expect(new TextEncoder().encode('a')).toEqual(new TextEncoder().encode('a')); // OK
  expect(Uint8Array.from([97])).toEqual(new TextEncoder().encode('a')); // FAIL: AssertionError: expected Uint8Array[ 97 ] to deeply equal Uint8Array[ 97 ]
});
System Info
node: v20.5.0, macOS
Used Package Manager

npm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Vitest reproduction and trace the equality assertion used by toEqual for Uint8Array and TextEncoder results. Add a regression test covering Uint8Array.from([97]) versus the encoded value, then verify that the test passes without changing the existing array comparisons.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.