Jest: Mock ES6 Module with both default and named export
问题 I have an ES6 module with both a default and a named export: /** /src/dependency.js **/ export function utilityFunction() { return false; } export default function mainFunction() { return 'foo'; } Its being used by a second ES6 module: /** /src/myModule.js **/ import mainFunction, { utilityFunction } from './dependency'; // EDIT: Fixed syntax error in code sample // export default myModule() { export default function myModule() { if (!utilityFunction()) return 2; return mainFunction(); } I'm