Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
Extraiga jest.mock para separar la función de utilidad

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!