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)
})
})