Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mock single function from module jest

import { functionToMock } from "@module/api";

jest.mock("@module/api", () => {
    const original = jest.requireActual("@module/api");
    return {
        ...original,
        functionToMock: jest.fn()
    };
});
 
PREVIOUS NEXT
Tagged: #mock #single #function #module #jest
ADD COMMENT
Topic
Name
6+3 =