Last active
February 20, 2019 11:40
-
-
Save rickhanlonii/bbdc87e4d8b26d0c13fb1715635ffb6f to your computer and use it in GitHub Desktop.
Mock Test with jest.mock
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
import * as app from "./app"; | |
import * as math from "./math"; | |
// Set all module functions to jest.fn | |
jest.mock("./math.js"); | |
test("calls math.add", () => { | |
app.doAdd(1, 2); | |
expect(math.add).toHaveBeenCalledWith(1, 2); | |
}); | |
test("calls math.subtract", () => { | |
app.doSubtract(1, 2); | |
expect(math.subtract).toHaveBeenCalledWith(1, 2); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍