Created
January 23, 2018 18:52
-
-
Save dschnare/91740fb1caf82d57512bfef15b9575f5 to your computer and use it in GitHub Desktop.
A simple test spy factory function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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