You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I am trying to write tests that involve making requests to hosted servers (via URL ) say(via agent1 and agent2) & local server(agent3). I want to fetch cookies from a server in agent1 and share that with agent2 and agent3. Is there a way to do it?
Sharing some code snippets for clarity in NodeJs.
import chai from 'chai';
import chaiHttp from 'chai-http';
import app from 'app.js';
let agent1 = chai.request.agent('https://server1.com/');
let agent2 = chai.request.agent('https://server2.com/');
let agent3 = chai.request.agent(app);
const getCookie = async () => {
return await agent1
.post('/signin')
.send({
email: '[email protected]',
password: '***',
});
};
describe('Do Checks', () => {
it('random', async (done) => {
const response = await getCookie();
await agent2
.post('/update/username')
.send({
"username": "rajchandra3"
})
.then(res=>{
//code is never executed
//do something with res
})
.catch(e=>{
throw e; //throws error because cookies are missing
});
done();
});
})
Can I share cookies between these agents?
The text was updated successfully, but these errors were encountered:
Hey, I am trying to write tests that involve making requests to hosted servers (via URL ) say(via
agent1
andagent2
) & local server(agent3
). I want to fetch cookies from a server inagent1
and share that withagent2
andagent3
. Is there a way to do it?Sharing some code snippets for clarity in NodeJs.
Can I share cookies between these agents?
The text was updated successfully, but these errors were encountered: