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

(new Uint8Array(8)).buffer instanceof ArrayBuffer is false when running with node 10.0.0 on macOS #6248

Closed
mstange opened this issue May 24, 2018 · 3 comments

Comments

@mstange
Copy link

mstange commented May 24, 2018

🐛 Bug Report

Updating to node version 10.0.0 caused a failure in our tests which boiled down to an instanceof ArrayBuffer check failing. Here's the reduced test:

expect((new Uint8Array(8)).buffer instanceof ArrayBuffer).toBe(true);

To Reproduce

Execute the test given above using node v10.0.0 on macOS.

Expected behavior

When dealing with a typed array, that array's buffer property should always be instanceof ArrayBuffer.

Link to repl or repo (highly encouraged)

https://github.com/mstange/jest-arraybuffer-testcase

Clone the repo, run yarn install, run yarn test, and you will see a test failure in the affected configuration.

$ yarn test
yarn run v1.6.0
(node:21279) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
$ jest
 FAIL  ./index.test.js
  ✕ ArrayBuffer test (7ms)

  ● ArrayBuffer test

    expect(received).toBe(expected) // Object.is equality

    Expected value to be:
      true
    Received:
      false

      1 | test('ArrayBuffer test', () => {
      2 |   const array = new Uint8Array(8);
    > 3 |   expect(array.buffer instanceof ArrayBuffer).toBe(true);
      4 | });
      5 |

      at Object.<anonymous>.test (index.test.js:3:47)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        0.63s, estimated 1s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Run npx envinfo --preset jest

Paste the results here:

$ npx envinfo --preset jest
npx: installed 1 in 2.091s

  System:
    OS: macOS Sierra 10.12.6
    CPU: x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
  Binaries:
    Node: 10.0.0 - /usr/local/bin/node
    Yarn: 1.6.0 - /usr/local/bin/yarn
    npm: 6.0.1 - /usr/local/bin/npm
  npmPackages:
    jest: ^22.4.4 => 22.4.4
@SimenB
Copy link
Member

SimenB commented May 25, 2018

@SimenB SimenB closed this as completed May 25, 2018
@wi-ski
Copy link

wi-ski commented Apr 18, 2020

This helped me: #7780 (comment)

@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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants