A markdown test
A mock function will give me some results, that we set. Why are we testing an empty function?
- The goal isn’t to test the mock function specifically but to test the function when we don’t have access to that function.
const add = jest.fn(() => 3)
This will mean whenenever add() is called, it returns 3
So why do we use mock functions? It’s fake - but it gives us results.
If we have a DB call, we don’t want it to hit the DB. So we can load up the call and turn it into a mock, then we can determine if that function is running.
- We can check how many times the function was called
- We can check what it was called with