求问,测试的时候怎么操作signedcookie和session
如题
3 回复
mocha+ supertest
describe('xxx', function(){
let signedCookies = null;
//set up a route to get signedCookie
app.get('/signedCookies', (req, res,)=>{
let cookie = req.query.cookie;
res.cookie('cookiename', cookie, {signed: true});
res.end();
})
it('should xxx', done=>{
request(app).get('/signedCookies?cookie=xxx').end((err, res)=>{
signedCookies = res.headers['set-cookie'];
request(app).get('/your root').set('Cookie', signedCookies).end((err, res)=>{
....
done();
})
})
})
})
就按这个思路走