Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Float32Array.buffer instanceof ArrayBuffer returns false in latest release #10786

Closed
gkjohnson opened this issue Nov 5, 2020 · 3 comments · Fixed by #10885
Closed

Float32Array.buffer instanceof ArrayBuffer returns false in latest release #10786

gkjohnson opened this issue Nov 5, 2020 · 3 comments · Fixed by #10885

Comments

@gkjohnson
Copy link

🐛 Bug Report

In the latest version of Jest (26.6.3) new Float32Array( 1 ).buffer instanceof ArrayBuffer returns false causing tests to fail.

To Reproduce

The following test fails in v26.6.3 but passes in v25.5.4 with no extra configuration:

describe('Float32Array.buffer', () => {
    it('should be an instance of ArrayBuffer', () => {
        expect(new Float32Array().buffer instanceof ArrayBuffer).toBeTruthy();
    });
});

Expected behavior

That new Float32Array().buffer instanceof ArrayBuffer return true like it does in the browser and node.

envinfo

  System:
    OS: macOS High Sierra 10.13.6
  Binaries:
    Node: 13.8.0
    Yarn: 1.10.1
    npm: 6.13.7
  npmPackages:
    jest: ^26.6.3 => 26.6.3 
@ExE-Boss
Copy link
Contributor

That’s because Jest uses a new VM context, and overrides the VM context’s ArrayBuffer with the top‑level global object’s ArrayBuffer, but doesn’t do this for typed arrays, which construct their ArrayBuffers using the overwritten ArrayBuffer constructor:

new Uint8Array().buffer.constructor !== ArrayBuffer;

Regressed by: #9606

@gkjohnson
Copy link
Author

Awesome -- thanks for the fix!

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants