If you’ve ever written unit tests, you’ve probably encountered situations where a function depends on an external API, a database, or a cloud service. These things are difficult to control in a test environment. This is where mocking comes in.