IssueRaiser

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

Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments

reliability (Software)

Jest globals differ from Node globals

thomashustonJan 10, 2017, 2:52 PM

**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.

Comment on this issue