在使用 Protractor 进行测试时,不是调用实际的 REST 端点——我可以用 json 文件替换结果吗?
Instead of calling actual REST endpoints when testing with Protractor -- can I replace the results with a json file?
在我的 angular 应用程序中,我能够在我的单元测试中使用 $httpbackend 来模拟返回的数据,但我希望能够在我的端到端测试中使用量角器做同样的事情.我找不到任何关于如何执行此操作的好资源?
例如,在我的单元测试中我能够做到这一点(GLOBAL.data 只是一个包含 JSON 的 js 文件)。
$httpBackend.expect('GET','http://myserver/somerestendpoint')
.respond(function(method, url, data, headers) {
console.log("Getting test response...");
return [200,{'data' : GLOBAL.data}, {/*headers*/}];
});
现在可以为我的端到端测试做类似的事情吗?
这就是 ngMocks 的目的
更具体地说
$http后端
在我的 angular 应用程序中,我能够在我的单元测试中使用 $httpbackend 来模拟返回的数据,但我希望能够在我的端到端测试中使用量角器做同样的事情.我找不到任何关于如何执行此操作的好资源?
例如,在我的单元测试中我能够做到这一点(GLOBAL.data 只是一个包含 JSON 的 js 文件)。
$httpBackend.expect('GET','http://myserver/somerestendpoint')
.respond(function(method, url, data, headers) {
console.log("Getting test response...");
return [200,{'data' : GLOBAL.data}, {/*headers*/}];
});
现在可以为我的端到端测试做类似的事情吗?
这就是 ngMocks 的目的 更具体地说 $http后端