When using Jest with the request lib (I also tried node-fetch and saw the same issue) to test a server response with multiple cookies returned, Jest will join the cookies into one string in the response object. Removing Jest resolves the issue.
Steps to reproduce the behavior: See Repl link below. Local test server works as expected without Jest.
index.js will execute the same logic without Jest first and the header is as expected. It will then execute the code through a Jest test file which then munges the set-cookie header value when multiple cookies are sent.
With a response header including multiple cookies (e.g. "foo=bar" and "bar=foo"), expect the response object from request to have a header value for set-cookie to be an array of those cookies (e.g. ["foo=bar", "bar=foo"]). However with Jest, the example header value would be ["foo=bar,bar=foo"].
A demo.
npx envinfo --preset jestPaste the results here:
System:
OS: macOS 10.14.2
CPU: (8) x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
Binaries:
Node: 8.11.1 - ~/.nvm/versions/node/v8.11.1/bin/node
npm: 6.5.0 - ~/.nvm/versions/node/v8.11.1/bin/npm
npmPackages:
jest: ^23.6.0 => 23.6.0
Updated demo code to use http module for making a request and the issue is still present once Jest is introduced.
The bug is most likely with node, prior v10. Jest runs every test suite with vm module. if you run your code as vm script without Jest, the same error occurs.

Upgrading node will solve the issue. I tested in node v10.10.0 and it behaves as expected.
Yeah, this is essentially a dupe of #2549. The case of http is fixed in Node 10 since they switched from instanceof Array to Array.isArray here: https://github.com/nodejs/node/pull/20250. If you can get them to backport this to node 8 it'll fix it in that version as well 馃檪
Most helpful comment
The bug is most likely with node, prior v10. Jest runs every test suite with
vmmodule. if you run your code asvmscript without Jest, the same error occurs.Upgrading node will solve the issue. I tested in node v10.10.0 and it behaves as expected.