Stubbing a class method with Sinon.js
问题 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 also went to this question (Stubbing and/or mocking a class in sinon.js?) and copied and pasted the code but I get the same error. Here is my code: Sensor = (function() { // A simple Sensor class // Constructor function Sensor(pressure) { this.pressure = pressure; } Sensor.prototype.sample_pressure = function() { return this.pressure