1
我如何窺視MyFunction
並在Jasmine 2.0中返回2
?如何間諜功能並返回茉莉花值
我有下面的代碼裏面shouldPass
在第一行錯誤:
Error: function MyFunction(){ return 1; }() method does not exist
這似乎是使用全功能的函數名
MyFile的。 js:
MyFunctionToTest = function(){
return MyFunction() + 1;
}
function MyFunction(){ return 1; }
MyFileSpec.js:
describe("myTest", function(){
it("shouldPass", function(){
spyOn("MyFile", MyFunction).and.returnValue(2);
expect(MyFunctionToTest()).toEqual(3)
})
})