【发布时间】:2015-07-10 09:05:52
【问题描述】:
我在使用 karma 进行单元测试时遇到了问题。
$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是否已定义? -
没有问题 - 您期待一些 PUT 调用,但从未发生 -
$httpBackend.flush()尝试刷新所有请求,但没有待处理的请求。 -
@KrzysztofSafjanowski 查看请求的 url =>
PUT undefinedcustomers/1 -
@ashish 看看
it部分 - 没有什么可以执行 PUT 查询 -
是的,将其更改为
whenPUT可能会修复它。 :)
标签: javascript angularjs unit-testing karma-jasmine