Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mock Test with jest.mock
import * as app from "./app";
import * as math from "./math";
// Set all module functions to jest.fn
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);

This comment has been minimized.

Copy link

@chestozo chestozo commented Jul 13, 2018


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment