0
我正在創建一個應用程序,其中包含要在登錄時發佈的功能。我在摩卡書寫了以下測試代碼。我得到這個錯誤:完成()在superagent請求內調用不起作用
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
我覺得我在做使用做了一些錯誤的()。所有其他斷言語句都已通過。讓我知道我哪裏錯了,或者如果你需要更多的信息。
it("Login and post", function(done) {
superagent
.post(URL_ROOT + "/register")
.send({
email: "[email protected]",
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();
});
});
});