I am creating an app with a feature to post on login. I have written the following test code in mocha. I get this error, "Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves". I think I made some mistake in using done(). All other assert statements have passed. Let me know where I am going wrong, or if if you need more info.
it("Login and post", function(done){
superagent
.post(URL_ROOT + "/register")
.send({
email: "posttest@test.com",
password: "posttest"
})
.end(function(err, res){
assert.ifError(err);
var token = res.body.token;
superagent
.post(URL_ROOT + "/post")
.send({
content: "testing post",
user: jwt.decode(token).id
})
.set("Authorization", "test_scheme " + token)
.end(function(err, res){
assert.ifError(err);
assert.equal(res.body.post.content, "testing post");
done();
});
});
});
Aucun commentaire:
Enregistrer un commentaire