vlucas / frisby

Frisby is a REST API testing framework built on Jest that makes testing API endpoints easy, fast, and fun.

Home Page:http://frisbyjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set cookies for current frisby version

amrsa1 opened this issue · comments

i have tried some script but so far non of them works with me and this script below is the last trial.

fit('6- 6th example log in using correct credential to staging expect status to be 304', function(){
return frisby
headers: {
cookie: res.headers.get('set-cookie')
}
.post('api url',{
redirect: 'https://mc.stage.att.com/',
reprompt: 'url',
username: 'userName',
password: 'PassWord',
})
.expect('status',302)
});

});
image

image

image

@amrkamel1

You need to convert set-cookie to cookie.

I used cookie-client in the past.

@H1Gdev @vlucas

Could you please provide a sample

`describe ('Backend Validation',()=> {

beforeAll(()=>{
    return frisby
        .setup({
            request: {
                redirect: 'manual',
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                }
            }
        })
        .post('https://login.com/EAI/Login', {
            body: qs.stringify({
                redirect: 'https://redirect.com',
                reprompt: 'https://reopromt.com/',
                username: 'user@user.com',
                password: '1123,
            })
        })
        .expect('status', 302)
        .inspectBody()
});

it('1- verify status code 200', ()=>{
      return frisby
        .setup({
            request: {
                redirect: 'manual',
                headers: {
                    'Content-Type': 'application/json',
                    'company-service': 'default'
                }
            }
        })

        .get('https://dashboard.com/users/current')
                .expect('status', 200)
                .inspectBody()
            .done(done);
        });

});

`

solved thx