I wish to stub a function used in the file I\'m currently testing. This function is required with a destructuring like this:
const { theFunctionIWant } = re
Since your module returns an object and theMethodIwant is property of that object you can define your stub like this:
theMethodIwant
const myModule = require('path/to/module') myModule.theMethodIwant = sinon.stub()