Loading
Current section: Functions 5 exercises
lesson

Intro to Functions

Loading lesson

Transcript

00:00 Functions are heart and soul of any logic in JavaScript. Handling user interactions, making network requests, processing data, all of those involve functions. Ideally, testing functions should come down to input-output testing. In other words, you supply the function with the right input and observe the right output.

00:18 For the most of it, that's how it's been done. But you see, functions much like the logic behind them can be very different. Some will be pure and you'll be able to test them just like that, but some will have dependencies or be asynchronous, or introduce side effects, and you have to account for all of that when testing. This is where mocking comes in, and I think it's about time you learn

00:38 three main techniques of mocking functions.