我有一些代码:
var bar = function() { ... };
var foo = function() { bar(); };
还有茉莉花测试:
describe('foo', function() {
it('calls bar', function() {
spyOn(window, 'foo'); // this line causes an error
spyOn(window, 'bar');
foo();
expect(bar).toHaveBeenCalled();
});
});
注释行导致此错误:
Expected spy bar to have been called.
Jasmine 是否foo
以某种方式监视其原生实现?如果我删除注释行,则测试通过。