question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clear cookies between requests

See original GitHub issue

I 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:closed
  • Created 10 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
ziyofuncommented, May 10, 2018

I find that the instance of supertest created byrequire('supertest').agent(server)will persist cookie between unit test. require('supertest')(server)will not.

1reaction
seonixxcommented, Jun 2, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found