I am writing some performance scripts using K6. I would like to create a user login from setup() method and use that cookie with request header of the next request within default() function. What's the easiest way to read browser cookies in K6? I had a look at cookieJar and response.cookies but it doesn't seem to be working.
Following code snippet works for this. The issue was that I previously used jar.cookiesForURL([DIRECTURL]) instead of jar.cookiesForURL(response.url)
let jar = http.cookieJar();
let cookies = jar.cookiesForURL(response.url);
console.log("CC::"+JSON.stringify(cookies));