forwardemail / forwardemail/supertest
Cookie names are converted to lower case, causing cookie assertion failures
- Dominant language
- JavaScript
- Stars
- 14.4k
- Forks
- 782
- PR merge metrics
- No merged PRs in 30d
Description
## Describe the bug
**Node.js version:** 16, but reproduced with 20 and 24 too.
**OS version:** Ubuntu 24.04
**Description:** cookie names are converted to lower case.
## Actual behavior
Given an app which sets a cookie `Foo=bar`:
```javascript
app.get('/v1/myroute', (req, res) => {
// Set a cookie with a mixed-case name
res.cookie('Foo', 'bar');
res.json({ message: 'Cookie set' });
});
```
When I write a test to expect the cookie `Foo`:
```javascript
const res = await request(app)
.get('/v1/myroute/')
.set('Accept', 'application/json')
.expect(200)
.expect(cookies.new({name: 'Foo', value: 'bar'}));
```
And I run `npm test`:
> Error: expected: Foo cookie to be set
Then the test fails.
## Expected behavior
The test passes.
## Code to reproduce
See this code reproducer: https://github.com/caarmen/supertest-cookie-issue/tree/main
And a failing test PR: https://github.com/forwardemail/supertest/pull/880
## Checklist
- [x] I have searched through GitHub issues for similar issues.
- [ ] I have completely read through the README and documentation.
- I read the cookies part in more detail, kind of skimmed through the rest of the README.
- [x] I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
Contributor guide
Assessment
This issue has not been assessed yet.