我試圖測試一個間諜將被稱爲承諾的.then
塊,但塊done
似乎並未執行在所有。摩卡 - 測試承諾,`完成`永遠不會被調用在承諾
我越來越timeout of 2000ms exceeded.
這裏是我測試(異步):
/**
* Passed down to the LoginForm component to
* handle form submission.
*/
_submitHandler(data) {
return function(evt) {
evt.preventDefault && evt.preventDefault();
evt.stopPropagation && evt.stopPropagation();
return request('post', 'auth', data)
.then((res) => {
AuthActions.login();
return res;
})
}
}
這裏是我的測試:
describe('when it succeeds',() => {
it('should login', (done) => {
sinon.spy(AuthActions, 'login');
Instance._submitHandler({})({})
.then((res) => {
console.log('Called!!!');
expect(AuthActions.login.called).to.equal(true);
AuthActions.login.restore();
done();
}, done);
});
});
我使用噶運行我的測試;柴和詩乃。
你會得到什麼失敗的消息? – Bergi