我将角度升级到1.6.1,角度ui-router升级到0.4.2。
我仍然收到此错误:/
app config中的解决方案:$qProvider.errorOnUnhandledRejections(false);
不干净:/
任何人都知道更好的解决方案吗?
这是我的测试代码:
beforeEach(function() {
inject(function ($injector) {
getResulfFile = $injector.get('GetResultFile');
httpMock = $injector.get('$httpBackend');
$q = $injector.get('$q');
deffered = $q.defer();
});
});
it('test promise reject of getResultFile.getResult', function() {
var message= "Not Found";
httpMock.expectGET('http://localhost:9999/v1/jmeter/' + id + '/results/' + rID).respond(500, message);
getResulfFile.getResult(id, rID).then(function(resp) {
}, function(resp) {
responseStatus = resp.status;
response = resp.data;
});
httpMock.flush();
expect(responseStatus).not.toBe(200);
expect(response).toBe('Not Found');
});