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鈥檒l 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鈥檚 because Jest uses a聽new聽VM聽context, and聽overrides the聽VM聽context鈥檚 ArrayBuffer with聽the聽top鈥憀evel global聽object鈥檚聽ArrayBuffer, but聽doesn鈥檛聽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
2 participants