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

120
Views
Mock testing function in JS

I have a func A() in class Characters.

I want to mock function A so I did this:

const char = new Character(); 
jest.spyOn(char, 'A').mockImplementation(async ({}) => {
     throw new Error('something'); 
})

When I try to run another function that uses A, for example getChars(). and I need to loop and run A a few times, I get to a point that I get to the ACTUAL original function A!

Why does this happen? why does this not use the mock function again? please help!

I tried changing the implementation but nothin worked.

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!