vitest-dev / vitest-dev/vitest
0.34.3 doens't work with `Uint8Array` and `TextEncoder`
Open
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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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