Stubbing a class method with Sinon.js

后端 未结 4 1986
无人共我
无人共我 2020-11-30 18:58

I am trying to stub a method using sinon.js but I get the following error:

Uncaught TypeError: Attempted to wrap undefined property sample_pressure as function

4条回答
  •  醉梦人生
    2020-11-30 19:49

    Thanks to @loganfsmyth for the tip. I was able to get the stub to work on an Ember class method like this:

    sinon.stub(Foo.prototype.constructor, 'find').returns([foo, foo]);
    expect(Foo.find()).to.have.length(2)
    

提交回复
热议问题