April 2018
Beginner
536 pages
13h 21m
English
We have learned that unit tests are used to test individual components, and integration tests are used to test a set of components and their interactions. When we write a unit test, and a component has a dependency on another, we will need to provide stubs, mocks, or dummies instead of real dependencies to ensure that the component is being tested in isolation. However, sometimes this can be more complicated than it sounds. Luckily, Sinon.JS can help us to ensure that our components are tested in isolation.
The following code snippet is used to test the web client of the pow web service that we described earlier in this chapter. We use Sinon.JS to define a stub for a global object named fetch. The fetch ...