Comments (8)
Hi @svallory thanks for the issue, and thanks for finding the underlying problem, good work!
cookie()
could probably assert on the agent
value, but couldn't do much with res
because - as you suggest - res no longer has 'set-cookie'
. So your assertion would have to be:
expect(agent).to.have.cookie('connect.sid')
It looks as though SuperAgent's Agent class keeps a this.jar
value inside an agent instance. So cookie()
could do a check to see if the object is an instance of our Test Agent, and then change the cookie to assert on, to the one inside Agent's cookie jar.
So to summarise, the code would go somewhere around 323-333 of http.js and look something like:
if (this._obj instanceof Test.Agent) {
cookie = this._obj.jar.getCookie(key, new Cookie.CookieAccessInfo());
} else {
cookie = Cookie.CookieJar();
cookie.setCookies(header);
cookie = cookie.getCookie(key, new Cookie.CookieAccessInfo());
}
If you'd like to make a PR for it @svallory, please do so, you'll need to write some tests, and improve the documentation, but doing so would get you on our awesome hall of fame which would net you a million internet points.
from chai-http.
Apparently express isn't sending a 'set-cookie' or a 'cookie' header
from chai-http.
Express wasn't sending the cookie because it had already been sent in previous request. I was using the same agent
for all my tests (bad idea). Still, this should be properly handled by chai-http, so I'm leaving it open.
from chai-http.
Hi @keithamus I'm trying to find the time to finish, or at least PR a WIP of chai messages refactoring. After that, if this is still hanging I can fix it.
from chai-http.
@svallory if you have anything at all, it's worth chucking it up as a WIP PR. Others can pick it up - or if you get stuck we can point you in the right direction. Also I try to make sure PRs aren't left to go stale, so having one open will receive semi-regular prodding from me 😉
from chai-http.
Hey @svallory. Do you have anything for this? If not I might just take a crack at it over the weekend.
from chai-http.
@keithamus Sorry, I don't. I simply created a new agent for each test and that solved it for me. Also, I'm really really busy and the message refactoring on chai is still hanging before this issue :/
from chai-http.
I'd like to work on this.
from chai-http.
Related Issues (20)
- How to check the contents of a binary response payload?
- Missing `exit` option in the API documentation, and the NodeJS API HOT 2
- Cannot read property 'headers' of undefined at Assertion.<anonymous> HOT 14
- Security Vulnerability: Update superagent Version to Fix! HOT 2
- Is there a way to share cookies between multiple agents?
- How do i POST xml request in chai? HOT 1
- Recommended way to extend the request class?
- Chai-http [POST] does not allow to send an Array on bodyParameters (API Testing & Javascript) HOT 1
- Superagent-proxy integration Failed
- Bump Chai-Http version to get package updates HOT 10
- Property 'request' does not exist on type 'Response'.ts (2339) HOT 3
- Issue with MongoDB ObjectId in tested function?
- Assertion error expending cookie
- [possibly bug] aws-sdk and multer-s3 with chai-http agent promise not resolved HOT 1
- Issues and PRs are piling. Are maintainers needed? HOT 1
- How to send gzip compressed body
- publish to npm actual version HOT 2
- Found CVE-2022-29622 in one of your dependent library- superagent
- How to send multiple json in post request using supertest
- Vulnerability in cookiejar CVE-2022-25901 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chai-http.