RunKit + npm: sinon

node v8.17.0
version: master
endpointsharetweet
const sinon = require('sinon@6.3.3'); const method = function() { return this.a; } const fakeMethod = sinon.fake(method); const o = { a: 'asdf', method: method, fakeMethod: fakeMethod, replacedMethod: method, explicitlyBoundMethod: method } sinon.replace(o, 'replacedMethod', sinon.fake(o.replacedMethod)); sinon.replace(o, 'explicitlyBoundMethod', sinon.fake(o.explicitlyBoundMethod).bind(o)); // i would hope this workaround would be considered unnecessary, even if it did work... console.log(o.method()) // 'asdf' console.log(o.fakeMethod()) // undefined console.log(o.replacedMethod()) // undefined console.log(o.explicitlyBoundMethod()) // undefined
Created from: https://npm.runkit.com/sinon
Loading…

no comments

    sign in to comment