我正在尝试以角度设置e2e测试套件,并且需要使用$ httpBackend返回预设响应.如果我能够返回文件内容,那将是很好的,例如
$httpBackend.whenPOST('/phones').respond(function(method, url, data) {
return getContentOf("/somefile");
});
Run Code Online (Sandbox Code Playgroud)
我尝试使用$ http,这是一些东西
$httpBackend.whenPOST('/phones').respond(function(method, url, data) {
return $http.get("/responses/phones.js");
});
Run Code Online (Sandbox Code Playgroud)
但它不起作用,猜角度不支持从$ httpBackend返回承诺?
我可以做的一种方法是引用带有应用程序加载响应的js文件,并将文件的内容分配给变量,但是能够按需加载数据会更好.