Transcript
00:00 I think you realize by now that mocking helps you deal with dependencies in your code. And your code can depend on so many things, from date and time, to making network requests, to using built-in APIs. But all of those dependencies can be split into two groups.
00:15 Explicit dependencies, things you import yourself, and implicit dependencies, in essence globals. In this exercise, you will be learning how to mock those global dependencies. And I'm pretty sure you used those in the past. Console.log is a great example of a global dependency. You're not importing the console object from anywhere. It is simply available
00:34 on the global scope in your app. But it's not only about built-in global APIs. You can introduce your own globals in your code if you configure your TypeScript and your build tooling to do that. But before you proceed into learning how to mock globals, I need to warn you. Mocking globals can be really dangerous, because effectively you are meddling with things you don't author and don't
00:55 own. You wouldn't want to mock something in the global process object to completely ruin how your tests run, right? So this is why it's extremely important to know how to mock globals in the least intrusive way. This is precisely what you're going to learn right now. We will be talking
01:10 about mocking global values, methods, and also environment variables. Let's begin.