如果被拒绝的承诺被抓住,如何使测试失败?
我正在尝试为异步登录功能设置角度服务测试。
如果它返回一个由承诺处理的被拒绝的承诺,则测试应该失败。但是测试始终是成功的。
打字稿
it('should sign-in with email and password', async(() => {
const service: AuthService = TestBed.get(AuthService);
// the strings can't be empty the service returns a rejected promise.
service.signInWithEmailAndPassword('', '').then(user => {
}).catch(error => {
fail();
});
}));
业力抛出此错误:
ERROR: 'Unhandled Promise rejection:', ''fail' was used when there was no current spec, this could be because an asynchronous test timed out', '; Zone:', 'ProxyZone', '; Task:', 'Promise.then', '; Value:', Error: 'fail' was used when there was no current spec, this could be because an asynchronous test timed out
Error: 'fail' was used when there was no current spec, this could be because an asynchronous test timed out