stubs/serialport.js
function SpyConstructor (opts) {
    Constructor.call(this, opts)

    // Spy on Constructor functions
    for (var key in this) {
      if (this[key] instanceof Function) {
        this[key] = sinon.spy(this[key])
      }
    }

    SpyConstructor.instances.push(this)
  }
function SpyConstructor (opts) {
    Constructor.call(this, opts)

    // Spy on Constructor functions
    for (var key in this) {
      if (this[key] instanceof Function) {
        this[key] = sinon.spy(this[key])
      }
    }

    SpyConstructor.instances.push(this)
  }
function SpyConstructor ( opts ) { Constructor . call ( this , opts ) // Spy on Constructor functions for ( var key in this ) { if ( this [ key ] instanceof Function ) { this [ key ] = sinon . spy ( this [ key ] ) } } SpyConstructor . instances . push ( this ) }
Wrap methods with spies and store instances
Wrap methods with spies and store instances