Description
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 #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
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 version and operating system.
I am using the default Jest configuration (I have not changed any settings in my package.json
).
Jest - 18.1.0
Node - 6.9.1 (also tested in 4.7.0 and saw the same error)
npm - 3.10.8
OS - Mac OS X 10.11.6