Quiero hacer una función general jest.mock para usar en múltiples archivos de prueba. El primer ejemplo funciona cuando uso jest.mock directamente dentro del archivo de prueba. Sin embargo, el segundo ejemplo no
// EXAMPLE 1 // this works jest.mock("third-paty-module", () => { return { MyComponent: props => { return <input {...props} />; } }; }); test("my test", () => { // then assert }); // EXAMPLE 2 // this doesn't work // test.config.js export function mockCustom() { jest.mock("third-paty-module-which-uses-webcomponents", () => { return { MyComponent: props => { return <input {...props} />; } }; }); } // file.test.js import { mockCustom } from "../../config/test.config.js"; mockCustom(); test("my test", () => { // then assert }); No obtengo errores cuando uso jest.doMock pero eso no se burla de mi componente en absoluto.