Giter Club home page Giter Club logo

Comments (8)

keithamus avatar keithamus commented on June 29, 2024 1

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.

svallory avatar svallory commented on June 29, 2024

Apparently express isn't sending a 'set-cookie' or a 'cookie' header

from chai-http.

svallory avatar svallory commented on June 29, 2024

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.

svallory avatar svallory commented on June 29, 2024

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.

keithamus avatar keithamus commented on June 29, 2024

@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.

keithamus avatar keithamus commented on June 29, 2024

Hey @svallory. Do you have anything for this? If not I might just take a crack at it over the weekend.

from chai-http.

svallory avatar svallory commented on June 29, 2024

@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.

yashsriv avatar yashsriv commented on June 29, 2024

I'd like to work on this.

from chai-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.