I am trying to set a cookie session to a post request in supertest but I cannot. This is my test code:
const app = express();
app.set("trust proxy", true);
app.use(json());
app.use(
cookieSession({
signed: false,
secure: process.env.NODE_ENV !== "test",
})
);
it("this is a test", async () => {
const response = await request(app)
.post("/api/users/current")
.set("Cookie", [
'express:sess=eyJqd3QiOiJleUpoYkdjaU9pSklVekkxTmlJc0luUjVjQ0k2SWtwWFZDSjkuZXlKcFpDSTZJakV5TXpRaUxDSmxiV0ZwYkNJNkluUmxjM1JBZEdWemRDNWpiMjBpTENKcFlYUWlPakUyTkRZeE5qazVNREI5LjZybE8zODB2RG1PN0J4cFlhRERZSnBScmhrMEc2X3pvN3BBd2MxYU5rMVEifQ=='
])
.send({});
expect(response.get("Set-Cookie")).toBeDefined();
});
and this test fails because response.get("Set-Cookie")
is undefined