forwardemail / forwardemail/supertest

Response cookies could be parsed

Open
#481 5 comments 14 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14.4k
Forks
782
PR merge metrics
No merged PRs in 30d

Description

Thank you for the great package. I use it all the time in my tests.

I'm testing response cookies and I realized in order to get response cookies I need to do something like this

.expect(res => {
console.log(res.headers['set-cookie'][0]);
});

And then dig through the set cookie header to verify that the correct cookie was returned. To make this easier, I converted the set-cookie header array to a dictionary using the [cookie](https://www.npmjs.com/package/cookie) module

> const cookie = require('cookie');
> cookie.parse('cookieName=cookieValue; path=/; expires=Thu, 16 May 2019 19:00:43 GMT; domain=.google.co; httponly')
{
cookieName: 'cookieValue',
path: '/',
expires: 'Thu, 16 May 2019 19:00:43 GMT',
domain: '.google.co'
}

If this was part of supertest and could be used as an object off of the response object, it would be very helpful. I imagine a format something like this:

> res.cookies
{
cookieName: {
value: 'cookieValue',
path: '/',
expires: 'Thu, 16 May 2019 19:00:43 GMT',
domain: '.google.com'
},
cookieName2: {
value: 'cookieValue2',
path: '/',
expires: 'Thu, 16 May 2019 19:00:43 GMT',
domain: '.yahoo.com'
},
}

What do you think? Good idea? Would you accept a PR for this?

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.