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
I ran into the same error trying to mock a method of a CoffeeScript class using Sinon.
Given a class like this:
class MyClass
myMethod: ->
# do stuff ...
You can replace its method with a spy this way:
mySpy = sinon.spy(MyClass.prototype, "myMethod")
# ...
assert.ok(mySpy.called)
Just replace spy with stub or mock as needed.
Note that you'll need to replace assert.ok with whatever assertion your testing framework has.