3 ms·
What you want to spy on are side-effects that are part of the function's contract. If you have a function that fetches data, you shouldn't test that its hittin
by ht85 8y ago
What you want to spy on are side-effects that are part of the function's contract.
If you have a function that fetches data, you shouldn't test that its hitting the data layer, only that the correct data is returned. This way when you improve the function to not hit the data layer at all under some conditions, your tests will keep passing.
On the other hand, if that function is supposed to log metrics or details about its execution, you should test that ,as it is part of its contract and can't be inferred from the return value.