Clear cookies between requests
See original GitHub issueI have some mocha tests using supertest and I’ve run into a case where independent tests (separate test files) are not re-initing the agent and start out in another test with the same cookie jar from the last.
I’m assuming this is because of the run-once nature of require
, and that I’m getting one singleton agent instance (I think I more or less verified this looking at the source.) Is there a way I can clear the cookiejar in the beforeEach
call in mocha?
Thanks!
Issue Analytics
- State:
- Created 10 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Clear cookies from Requests Python - Stack Overflow
The Session.cookies object implements the full mutable mapping interface, so you can call: s.cookies.clear(). to clear all the cookies.
Read more >cookies.remove() - Mozilla - MDN Web Docs
The remove() method of the cookies API deletes a cookie, given its name and URL. The call succeeds only if you include the...
Read more >Solved: A Script to Clear Cookies in an API Request
Here is the task: create a Groovy script that will clear the cookies that are sent with the request. Difficulty: Star_Gold.png Star_gray.png.
Read more >clearCookies - Cypress Documentation
Clear browser cookies for a domain. Cypress automatically clears all cookies before each test to prevent state from being shared across tests when...
Read more >How to clear cookie after an Request - Help - Postman
I have a use case's, where I need to clear cookies after some set of requests. but when I ran suite, cookies of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I find that the instance of supertest created by
require('supertest').agent(server)
will persist cookie between unit test.require('supertest')(server)
will not.Did anyone ever find a solution for this? I’ve been using set(‘Cookie’, []) on the required requests but am hoping there is a more elegant solution.