forwardemail / forwardemail/supertest

Cookie names are converted to lower case, causing cookie assertion failures

Open
#879 0 comments 0 reactions 0 assignees View on GitHub
bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.