Jest globals differ from Node globals
**Do you want to request a *feature* or report a *bug*?** Bug **What is the current behavior?** After making a request with Node's `http` package, checking if one of the response headers is an `instanceof Array` fails because the `Array` class used inside `http` seems to differ from the one available in Jest's VM. I specifically came across this when trying to use `node-fetch` in Jest to verify that cookies are set on particular HTTP responses. The `set-cookie` header hits this condition and fails to pass in Jest https://github.com/bitinn/node-fetch/blob/master/lib/headers.js#L38 This sounds like the same behavior reported in https://github.com/facebook/jest/issues/2048; re-opening per our discussion there. **If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can `yarn install` and `yarn test`.** https://github.com/thomas-huston-zocdoc/jest-fetch-array-bug **What is the expected behavior?** The global `Array` class instance in Jest should match that of Node's packages so type checks behave as expected. I've submitted a [PR to `node-fetch`](https://github.com/bitinn/node-fetch/pull/220) switching from `instanceof Array` to `Array.isArray` to address the immediate issue, but the Jest behavior still seems unexpected and it took quite a while to track down. **Please provide your exact Jest configuration and mention your Jest, node, yarn/npm versio
Posted by thomashuston on Jan 10, 2017, 2:52 PM
Tags
Related issues
- [BUG] Cowork (Windows): all Plan9 shares fail with "Plan9 mount failed: invalid argument" after Windows update KB5124008 (26200.9445) — uninstalling the KB fixe
- Feature Request: Auto-resume CLI session when usage limit resets
- Please deobfuscate the Python
- [Bug] MLX version of Gemma 4 26B fails to load: "Model type gemma4 not supported" (macOS)
- # 233 Developers Discussed Abandoning the Office Add-in Platform — An Open Letter on the Office.js Stability, Security & Trust Crisis
- [FEATURE] Allow users to configure which shell the Bash tool uses or inherit initial shell
Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments
reliability (Software)
[BUG] Cowork (Windows): all Plan9 shares fail with "Plan9 mount failed: invalid argument" after Windows update KB5124008 (26200.9445) — uninstalling the KB fixe
Feature Request: Auto-resume CLI session when usage limit resets
Please deobfuscate the Python
[Bug] MLX version of Gemma 4 26B fails to load: "Model type gemma4 not supported" (macOS)
# 233 Developers Discussed Abandoning the Office Add-in Platform — An Open Letter on the Office.js Stability, Security & Trust Crisis
[FEATURE] Allow users to configure which shell the Bash tool uses or inherit initial shell
Admin Materials and Surfaces
AMD Support
Jest globals differ from Node globals
**Do you want to request a *feature* or report a *bug*?** Bug **What is the current behavior?** After making a request with Node's `http` package, checking if one of the response headers is an `instanceof Array` fails because the `Array` class used inside `http` seems to differ from the one available in Jest's VM. I specifically came across this when trying to use `node-fetch` in Jest to verify that cookies are set on particular HTTP responses. The `set-cookie` header hits this condition and fails to pass in Jest https://github.com/bitinn/node-fetch/blob/master/lib/headers.js#L38 This sounds like the same behavior reported in https://github.com/facebook/jest/issues/2048; re-opening per our discussion there. **If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can `yarn install` and `yarn test`.** https://github.com/thomas-huston-zocdoc/jest-fetch-array-bug **What is the expected behavior?** The global `Array` class instance in Jest should match that of Node's packages so type checks behave as expected. I've submitted a [PR to `node-fetch`](https://github.com/bitinn/node-fetch/pull/220) switching from `instanceof Array` to `Array.isArray` to address the immediate issue, but the Jest behavior still seems unexpected and it took quite a while to track down. **Please provide your exact Jest configuration and mention your Jest, node, yarn/npm versio
Comments (0)
No comments yet. Start the discussion.