Created
September 26, 2020 12:45
-
-
Save janhesters/46fd9cfe2f59efbc15fd3c8beda0cfe2 to your computer and use it in GitHub Desktop.
The mock function.
This file contains 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 fn(implementation = () => {}) { | |
const mockFn = (...args) => { | |
mockFn.calls.push(args); | |
return implementation(...args); | |
}; | |
mockFn.calls = []; | |
return mockFn; | |
} | |
export default fn; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment