Skip to content

Instantly share code, notes, and snippets.

@dschnare
Created January 23, 2018 18:52
Show Gist options
  • Save dschnare/91740fb1caf82d57512bfef15b9575f5 to your computer and use it in GitHub Desktop.
Save dschnare/91740fb1caf82d57512bfef15b9575f5 to your computer and use it in GitHub Desktop.
A simple test spy factory function
function spy (fn = () => {}) {
f.calls = []
function f (...args) {
const returnValue = fn(...args)
f.calls.push({ args, returnValue })
return returnValue
}
return f
}
exports.spy = spy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment