I am trying to spy on a global function e.g.
function foo() {
}
but the below test is failing, how to do that
var spy = sinon.spy(foo);
foo();
expect(spy.callCount).to.equal(1);
** EDIT **
If I do it like below then it works
var spy = sinon.spy(window, "foo");
foo();
expect(spy.callCount).to.equal(1);
So whats the difference