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

268
Views
Is it possible to prevent higher order function execution in Jest test, if passed callback is a mock?

I have a function which makes a lot of calculations and returns order of sorting. For that function I have tests. Then, that function is used inside of JS native sort method. In that case, I mock my compare function, just to test if it was called with proper parameters.

Code looks like this:

const output = Object.keys(options).sort(compare(param1, param2)); 

compare here is a mock, I check if it was called, check if it was called with proper params.

Is it possible to stop sort execution, or it automatically stops, when it sees it's a mock? I couldn't find any source, that will match my question.

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!