...

/

Spies, Stubs, and Clocks

Spies, Stubs, and Clocks

Learn what spies, stubs, and clocks are, and how they can control the behavior of our application.

First and foremost, why do we need to control some of the behaviors of our application? Wouldn’t we want to test it from a user’s perspective without modifying anything programmatically? There can be several reasons for controlling the original behavior of our app. Let’s take a look at some.


Reasons for controlling behavior

When we want to modify the behavior of our application, here are a couple of scenarios that will make our test suite more robust:

  • Avoid side effects, such as a bad network connection
  • We are dealing with Promises, and we want to automatically resolve or reject them.
  • We want to force things to fail to test a failure path.
  • We want
...