Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: sinon
node v8.17.0
version:
master
endpoint
share
tweet
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