I was all set up for the pain of stubbing Node.js dependencies, but you can just use the
import * as blah from 'blah' syntax to obtain an object with properties that can be stubbed using either TestDouble or Sinon.
The object is shared between modules at runtime, so modifications will propagate everywhere. Be sure the use Sinon's
restore() or TestDouble's
reset() methods to return the module to it's normal state so that it doesn't bleed into other tests.
If you need to stub a default module function, then use this import
import * as kphToMphModule from '../src/kphToMph';
and stub with testdouble like this:
const kphToMph = td.replace(kphToMphModule, 'default');
or with Sinon:
const kphToMph = sinon.stub(kphToMphModule, 'default');