Mocking is a way to test code that has external dependencies, which are hard to include in a unit test. An example is an alarm clock that triggers a function at a specific time, but you do not want to execute your test at exactly this time to test the condition.
Click here to learn more.