-
I'm noticing that in my tests, any cookies that were set previously, are leaking into other requests. The problem is that I have some requests that need the cookies to be empty. I've worked around this by initializing a new httpexpect object in tests where I don't want any prior requests' cookies set. The workaround:
Is there a recommended best practice for this sort of case? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi, did you try to create a httpexpect object with https://github.com/gavv/httpexpect#session-support This should disable cookies completely. Or do you need to disable cookies on per-request basis? |
Beta Was this translation helpful? Give feedback.
-
You can also create different http.Client instances, e.g. with and without cookie jar, and select a different client for each request using WithClient method. |
Beta Was this translation helpful? Give feedback.
-
In this case, I need cookies disabled on a per request basis. Thank you, I'll take a look at that/try that |
Beta Was this translation helpful? Give feedback.
-
Closing, feel free to reopen if needed. |
Beta Was this translation helpful? Give feedback.
Hi, did you try to create a httpexpect object with
Client.Jar
set tonil
, as described here?https://github.com/gavv/httpexpect#session-support
This should disable cookies completely.
Or do you need to disable cookies on per-request basis?