Book Image

WEB APP TESTING USING KNOCKOUT.JS

By : Roberto Messora
Book Image

WEB APP TESTING USING KNOCKOUT.JS

By: Roberto Messora

Overview of this book

Table of Contents (11 chapters)

Spies


A test double is a fundamental topic, which talks about unit testing. Jasmine provides its own implementation called spies.

Note

A test double is a particular object used to replace another object originally involved in the code under the test. Usually, a test double is a simplified version of the original one that behaves the same way and can be easily controlled during the test execution. The objective is to isolate the test execution context from everything that is not directly related to the test subject. In other words, if we want to test the behavior of a particular object that has some sort of interaction with other objects, we need something to tightly control the latter so that we can accurately define the execution context.

A spy is a function that can stub any other function and track all the calls and every argument passed. The following example (03_03_specs.js) shows the basic spy functionality. Remember that here we want to show how it works technically, not how we can take...