Stubbing window.location.href with Sinon
问题 I am trying to test some client-side code and for that I need to stub the value of window.location.href property using Mocha/Sinon. What I have tried so far (using this example): describe('Logger', () => { it('should compose a Log', () => { var stub = sinon.stub(window.location, 'href', 'http://www.foo.com'); }); }); The runner displays the following error: TypeError: Custom stub should be a function or a property descriptor Changing the test code to: describe('Logger', () => { it('should