Skip to content

Instantly share code, notes, and snippets.

@rickhanlonii
Last active February 24, 2022 06:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rickhanlonii/2bdc004d56e329fa149bcf9eeafa75cd to your computer and use it in GitHub Desktop.
Save rickhanlonii/2bdc004d56e329fa149bcf9eeafa75cd to your computer and use it in GitHub Desktop.
Mock Function Basic
test("returns undefined by default", () => {
const mock = jest.fn();
let result = mock("foo");
expect(result).toBeUndefined();
expect(mock).toHaveBeenCalled();
expect(mock).toHaveBeenCalledTimes(1);
expect(mock).toHaveBeenCalledWith("foo");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment