Unintuitive Set-Cookie behavior
See original GitHub issueconst request = require('supertest');
const app = require('express')()
.get('/cookies', (req, res, next) => {
res.cookie('one', '1');
res.cookie('two', '2');
res.json(res._headers['set-cookie']);
});
describe('/cookies', () => {
it('should have correct anatomy', () =>
request.agent(app)
.get('/cookies')
.expect(200, ['one=1; Path=/', 'two=2; Path=/']) // This is what I expect below
.then(res => {
expect(res.headers['set-cookie'].length).toBe(1); // should be 2
expect(res.headers['set-cookie']).toEqual(['one=1; Path=/,two=2; Path=/']); // why is this a single string?
})
);
});
No?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Unintuitive Set-Cookie behavior · Issue #413 · ladjs/supertest
agent(app) .get('/cookies') .expect(200, ['one=1; Path=/', 'two=2; Path=/']) // This is what I expect below .then(res => { expect(res.headers[' ...
Read more >php - Why are my cookies not setting? - Stack Overflow
The problem comes from the fact that setcookie() doesn't set the cookies immediately, it sends the headers so the browser sets the cookies....
Read more >Cookie storage behavior - HTTPie 3.2.1 (latest) docs
There are three possible sources of persisted cookies within a session. They have the following storage priority: 1—response; 2—command line; 3—session file ...
Read more >PHP :: Bug #67736 :: setcookie() not updating existing cookies
The idea of having setcookie magically modifying the cookie header that is sent is not good. It would be adding more magic behaviour...
Read more >Set-cookie ignored for HTTP response with status 302 - Monorail
Not on Ubuntu Version 24.0.1312.52 m though, strange issue. The issue is as is, Cookie's does not being set while sending 302 response...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh that is odd. I just tried with mocha and am getting
whereas jest is getting
I’ll have to dig into what they’re doing…
Thanks
👍, looks like I’m hitting this exact issue too. Also running jest.
For people coming here via google, here is a workaround: https://github.com/facebook/jest/issues/3547#issuecomment-302550427