ale*_*333 5 javascript jasmine angularjs
我的代码中有以下行:
var fileUrl = URL.createObjectURL(file);
Run Code Online (Sandbox Code Playgroud)
不幸的是 phantomjs 没有 URL,所以我需要在 Jasmine 中存根,但不确定如何。
我正在使用 Jasmine 2 和 AngularJS 1.4
spyOn(URL, 'createObjectURL').and.returnValue("something");
Run Code Online (Sandbox Code Playgroud)
这假设 URL 在您的单元测试中是可访问的。或者,另一种方法是将单元测试中的 URL 定义为...
var URL = {
createObjectURL: function() { return "something" }
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1300 次 |
| 最近记录: |