Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@SimenB
Copy link
Member

@SimenB SimenB commented Jul 11, 2024

Summary

This partially addresses #15176, in that it

  • makes toEqual call drop from 500ms to 100ms (due to us not using the iterator, but iterating "normally" which is 5x faster)
  • if reproduction is changed to toStrictEqual it drops to 3-4 ms, comparable to lodash implementation (without the changes in this PR, there is no difference between toEqual and toStrictEqual)

There might be a case for us to include arrayBufferEquality in the custom matchers we use in toEqual here:

const pass = equals(received, expected, [
...this.customTesters,
iterableEquality,
]);

In that case, toEqual also drops down to 3-4 ms runtime.

Test plan

Tests added

@netlify
Copy link

netlify bot commented Jul 11, 2024

Deploy Preview for jestjs ready!

Name Link
🔨 Latest commit e52054e
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/668fb68101a6fd00080bc250
😎 Deploy Preview https://deploy-preview-15178--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

const a = Uint8Array.from([2, 4]).buffer;
const b = Uint16Array.from([1, 7]).buffer;
expect(arrayBufferEquality(a, b)).not.toBeTruthy();
expect(arrayBufferEquality(a, b)).toBe(false);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a separate bug - it returned undefined, not false since Uint16Array.from([1, 7]).buffer instanceOf ArrayBuffer for some reason is `false.

let dataViewB = b;

if (a instanceof ArrayBuffer && b instanceof ArrayBuffer) {
if (isArrayBuffer(a) && isArrayBuffer(b)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimenB SimenB enabled auto-merge (squash) July 11, 2024 12:05
@SimenB SimenB merged commit 19b3bcc into jestjs:main Jul 11, 2024
@SimenB SimenB deleted the compare-all-dataview-properly branch July 11, 2024 12:05
@github-actions
Copy link

This pull request 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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant