NodeJS by Example: Mocking
The core Node:test module supports mocking via a top-level `mock` object. 1. The mock object has a `fn` method that returns a mock function. You can then assert values such as the number of times the function was called, the arguments it was called with, and the return value. |
|
2. Mocking timers allows you to simulate the behavior of the Node.js timers such as `setTimeout` and `setInterval`. This allows you to test code that uses timers without having to wait for the timers to expire. |
|
|
|