You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected this to fail, but it passed.
Looking through .toStrictEqual() I see that it compares the .byteLength field only - as contents of ArrayBuffer is not directly accessible.
To compare ArrayBuffers, You need to wrap it as DataView and compared byte-by-byte.
I know that this may be out of .toStrictEqual() scope, but IMHO even if its not implemented there it deserves some kind of warning when this matcher is passed ArrayBuffer as arguments.
Motivation
If this should not be implemented in core, at least warn users about possible false positives.
Example
$ jest FAIL lib/arraybuffer.spec.ts ✕ invalid input (8 ms) ● compare array buffers expect(received).toStrictEqual(expected) // deep equality ! Note: comparing `ArrayBuffer` can give you false-positives
Pitch
Additional warning for base matcher, or add support for a 'special care' data type...
The text was updated successfully, but these errors were encountered:
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
🚀 Feature Proposal (or maybe 🐛 Bug Report)
Note: This may be in some way related to previously reported bug #6109. But that case didn't come with enough details for some acceptable solution.
I'm writing some tests for data structures based on ArrayBuffers and have run into an issue with the code below:
I expected this to fail, but it passed.
Looking through
.toStrictEqual()
I see that it compares the.byteLength
field only - as contents ofArrayBuffer
is not directly accessible.To compare
ArrayBuffers
, You need to wrap it asDataView
and compared byte-by-byte.I know that this may be out of
.toStrictEqual()
scope, but IMHO even if its not implemented there it deserves some kind of warning when this matcher is passedArrayBuffer
as arguments.Motivation
If this should not be implemented in core, at least warn users about possible false positives.
Example
Pitch
The text was updated successfully, but these errors were encountered: