chaijs / chai-http

HTTP Response assertions for the Chai Assertion Library.
http://chaijs.com/plugins/chai-http
632 stars 112 forks source link

Assertion error expending cookie #297

Open Jidarofa opened 3 years ago

Jidarofa commented 3 years ago

Hello I have the follow code

it("it should gives the token", (done) => {
            var agent =  chai.request.agent(url)
            agent
                .post('path')
                .set({
                    "Content-Type": "application/x-www-form-urlencoded",
                })
                .send({
                    "username":"user",
                    "password":"ps",
                    "domain":"ForAllDomains",
                    "authMode":"user",
                    "state":"",
                    "__oauinst__":""
                })              
                .end((err, res) => {
                    expect(res).to.have.cookie('.BzSSO')

But when i want to have the cookie is't possible because appear the next error:

Uncaught AssertionError: expected cookie '.BzSSO' to exist

real response:

headers: {
    date: 'Wed, 18 Aug 2021 16:46:40 GMT',
    'content-type': 'text/plain; charset=utf-8',
    'content-length': '155',
    connection: 'close',
    'cache-control': 'no-cache, no-store',
    pragma: 'no-cache',
    'content-encoding': 'gzip',
    expires: '-1',
    vary: 'Accept-Encoding',
    'set-cookie': [
      '.BzSSO=CfDJ8KfvN9uUUfFEqXxmsdwgrYPk07XJVYGFBc_fIVMPwSFgPm01pvGfUt4rBsDdhQIo3hpsY8HpN30ag7PstNz9rMbthHmD__a7G7DZrHcip9yoO21KnXgNKZrIDpGWr_7zjwC8fL-hY8ETNcSDwy-jYAMW2TE-mHOcGWoHIiJWj7TopzobnDKMFHlPSvyLk6WfSC_iIb0XOePNGQVLW0wGNlutxAYXYmYjtGdmrrFGWrk09JqxAZHdbWxkjeX5qmJro7OITOjJY0EfJopdE3pZH4oL089SKhpv2f1syRutVI__jbYjWw6CDY3eyy98BY; expires=Sat, 28 Aug 2019 16:46:40 GMT; domain=accounts-cuaderno.bizagi.com; path=/; secure; samesite=strict; httponly'
    ],