Last active
February 24, 2022 06:07
-
-
Save rickhanlonii/2bdc004d56e329fa149bcf9eeafa75cd to your computer and use it in GitHub Desktop.
Mock Function Basic
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
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