![](/img/trans.png)
[英]Angular.js promise not resolving when unit testing service with karma
[英]Karma Angular.js unit test expectPUT
我使用业力进行单元测试时遇到问题。
$httpBackend.expectPUT(envConfig.restUrl + 'customers/1').respond(200);
it('should update"customer details" model', function() {
expect(scope.customerDetails).toBeUndefined();
$httpBackend.flush();
和响应:
Error: Unsatisfied requests: PUT undefinedcustomers/1
at Function.$httpBackend.verifyNoOutstandingExpectation
您的envConfig.restUrl
未定义。
根据@KrzysztofSafjanowski注释,您也不在调用可能会执行该PUT
请求或手动执行的函数。 将其更改为whenPUT
可能会解决此问题:
$httpBackend.whenPUT(envConfig.restUrl + 'customers/1').respond(200);
it('should update"customer details" model', function() {
expect(scope.customerDetails).toBeUndefined();
$httpBackend.flush();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.