I have a file with two function
export default function fetcher(){
....
}
export function configure(){
...
}
when I want to make a mock on default exported I write such
jest.mock('../../src/path', () => {
return jest.fn()
});
when I want to make a mock on regular exported I write such
jest.mock('../../src/path', () => {
return {
configure: jest.fn(),
};
});
My problem is when I need to mock two functions Of both types in one file
import defFunction, { configure } from '..src/path';
One mock overturns the other
CodePudding user response:
Try:
jest.mock('../../src/path', () => {
const defaultExport = jest.fn();
defaultExport.configure = jest.fn();
return defaultExport;
});