0
私は拒否テストする必要があります方法:チャイ約束した試験拒否タイムアウトなど
私のテストでreturn new Promise(function(resolve, reject){
models.users.find({
where: {
email: email
}
}).then(function(result){
if(!result)
throw 'Invalid password'
}).catch(function(err){
reject(err);
});
});
:
it('should be rejected', function(){
let data= { req: {
email: '[email protected]',
}};
return User.authUser(data).should.be.rejected;
});
それは聖霊降臨祭エラー「無効なパスワード」を拒否しなければならないが、私はエラーを取得:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure
it resolves.
:
とあなたのテストで:例外は約束を拒否し、あなたは別の約束でそれをラップするべきではありませんので、 あなたは約束を拒否する必要はありません。 find() 'がすでに約束を返しているので、' new Promise'を使ってそれをラップするべきではありません。 FWIW、あなたのコードは 'resolve()'を呼び出すことはありません... – robertklep