I am writing unit tests in Ember-qunit. I want to set a custom value on performance.now.
I tried sinon.stub(performance,'now', 60000); but this didn't work. I get TypeError: stub(obj, 'meth', fn) has been removed.
how do i stub performance.now() using sinon.js?
Thanks
Not sure what your third argument (
60000) is supposed to be as I am not familiar withperformance.now(), but that's not a valid call toSinon.stub()(there is no 3rd parameter). Per the documentation though, you should be able to capture the stub function and then call a method on it to indicate the desired return value:Then, when the stub is called, you should get:
You can see this functionality in this jsfiddle example.