-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Fix buffer property is not ArrayBuffer issue. #7626
Conversation
In node environment Buffer class buffer property become ArrayBuffer. * Set ArrayBuffer to global.ArrayBuffer. * Add tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks! I've verified in the node repl that they should pass instanceof
, so this change is correct
Mind updating the changelog? 🙂
* Add jestjs#7626 to CHANGELOG.
Codecov Report
@@ Coverage Diff @@
## master #7626 +/- ##
==========================================
- Coverage 68.27% 68.26% -0.01%
==========================================
Files 249 249
Lines 9623 9624 +1
Branches 5 6 +1
==========================================
Hits 6570 6570
- Misses 3051 3052 +1
Partials 2 2
Continue to review full report at Codecov.
|
There was an unfortunate quirk of upgrading Jest. They changed their node globals to include an `ArrayBuffer` override, synchronizing the value with `Buffer.from([]).buffer.constructor`. I didn't dive too deep, but what became clear was `new Uint8Array(0).buffer` and `Buffer.from([]).buffer` reference different `ArrayBuffer` constructors. This failed the tests because I was comparing the constructor from two separate realms. See: jestjs/jest#7626 This affects production code, not just tests. Because the global constructor was different between environments, it forced me to check by string tag instead of instance. That's probably a good change anyway. I manually checked the string tag in Node, IE11, Firefox, and Chrome.
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. |
In node environment Buffer class buffer property become ArrayBuffer.
Summary
In the following code.
Execute in each environment.(
--env=node
,--env=jsdom
, andnode
)Expect:
Actual:
--env=node
, (A) is not true.ref.
https://nodejs.org/api/buffer.html#buffer_buf_buffer
Test plan