'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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
