supertest-cookie-parser
v1.0.0
Published
Parse cookies from Supertest response header
Downloads
10
Maintainers
Readme
This library parses cookies from the response header and populates the response object with an object containing key-value pairs, where each cookie name is a key and its corresponding cookie value is the value.
Usage/Examples
supertest-cookie-parser exposes a function that, when invoked with an HTTP response object as the argument, gives you access to the parsed cookies through the response.cookies property.
const request = require("supertest");
const parseCookies = require("supertest-cookie-parser");
const server = require("./startup/server");
describe("check sessionID", () => {
it("should parse cookies & check whether sessionID exists or not", async () => {
const response = await request(server).get("/");
parseCookies(response); // A response object must be passed as the arugment
expect(response.cookies).toHaveProperty("sessionID");
expect(response.cookies.sessionID).not.toBeNull();
});
});