Skip to content

Instantly share code, notes, and snippets.

@janhesters
Created September 26, 2020 12:45
Show Gist options
  • Save janhesters/46fd9cfe2f59efbc15fd3c8beda0cfe2 to your computer and use it in GitHub Desktop.
Save janhesters/46fd9cfe2f59efbc15fd3c8beda0cfe2 to your computer and use it in GitHub Desktop.
The mock function.
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