I played with Mocha Testing. I have noticed that my function throws Warring of "UnhandledPromiseRejectionWarning" in few places. It makes the script to do not pass the check.
I could not find useful example on the internet that will teach/show a good way to fix the problem. Maybe one of you can help.
If you have any other comments to my code please feel free to share. I am here to learn :)
Function where the problem occurs.
it('/POST /logout => Logout a user by purging a session', (done) => {
let loginInfo = {};
loginInfo.usr = 'testuser';
loginInfo.psw = 'mochatesting197';
let agent = chai.request.agent(app);
let json = {};
json.logout = true;
agent.post('/login')
.send(loginInfo)
.then((res) => {
return agent.post('/logout')
.send(json)
.then((res) => {
res.should.have.status(200);
res.body.should.be.a('object');
res.body['success'].should.have.property('message').eql('YOU HAVE LOGGED OUT');
done();
}).catch(function (err) {
throw err;
});
});
});
Aucun commentaire:
Enregistrer un commentaire