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/mock performance.now() using sinon.js?
Thanks
Hey @kumar_b, I ran into this question while researching for my EmberFest talk about Sinon.JS. I’ve noticed this topic is a bit old, but I think it’s worth to leave an updated solution to this.
The syntax you tried to use was removed on version v3.0.0, according to the documentation. If you use this one instead it should work:
sinon.stub(performance, 'now').returns(60000);