Is there any common storage medium available in k6?. My usecase is I need to send cookies to each and every request header. Cookies will be set during signin. For each and every workflow I am requesting signin which seems costly. Any workaround in storing the cookies, so that i can access and send to each and every request.
Welcome to the forum. If the website you’re testing allows it, you can get/set the cookies once in
setup as a global variable and then simply re-use them in
default function. As for the storage medium, there is a cookie jar object which can be used at any level of test execution. Please see the docs:
For example, you can declare global
jar object and use
jar.cookiesForURL(url) method in
setup to get cookies for that url and then set them in
http calls. Hope that helps!