Skip to content

Test for cookie case#882

Open
dmurvihill wants to merge 3 commits intoforwardemail:masterfrom
dmurvihill:test-for-cookie-case
Open

Test for cookie case#882
dmurvihill wants to merge 3 commits intoforwardemail:masterfrom
dmurvihill:test-for-cookie-case

Conversation

@dmurvihill
Copy link
Contributor

Includes @caarmen's test from #880 as well as a fix for the underlying problem.

Checklist

  • I have ensured my pull request is not behind the main or master branch of the original repository.
  • I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
  • I have written a commit message that passes commitlint linting.
  • I have ensured that my code changes pass linting tests.
  • I have ensured that my code changes pass unit tests.
  • I have described my pull request and the reasons for code changes along with context if necessary.

caarmen and others added 2 commits February 25, 2026 16:26
All cookie keys were being lower-cased before comparison, but actually
case should be preserved for the first key (the cookie-name).

See also: [RFC 6265](https://datatracker.ietf.org/doc/html/rfc6265)
Copy link

@A1exKH A1exKH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall idea of this test looks good, to finalize this code review we need some additional information from author of PR.

test/cookies.js Outdated
.expect('Content-Length', '15')
.expect(200)
// assert 'Alpha' cookie is set with domain, path, and httpOnly options
.expect(cookies.set({ name: 'Alpha', options: ['domain', 'path', 'httponly'] }))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmurvihill could you share more details about this code, please?
As I can see cookies.set and cookies is not a standard global object in Supertest.

In standard Supertest, you cannot pass an object like { name: 'Alpha' } directly into .expect(). Instead, you have to parse the Set-Cookie header string.
Here you can find some details:
#665

Copy link
Contributor Author

@dmurvihill dmurvihill Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cookies was added in supertest 7.2 (#855). See cookies.set.

test/cookies.js Outdated
});
});

describe('Cookie name case is respected', function () {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about this version of code to make it clearer:

describe('Cookie Case Sensitivity', function () {

it('should respect capital letters in cookie names', async function () {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to respects case of cookie name and moved up with the rest of the tests for .set.

Copy link

@A1exKH A1exKH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@dmurvihill thanks for information and updates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants