© Panos Matsinopoulos 2020
P. MatsinopoulosPractical Test Automationhttps://doi.org/10.1007/978-1-4842-6141-5_2

2. Advanced Jasmine

Panos Matsinopoulos1 
(1)
KERATEA, Greece
 
This chapter introduces you to two very widely used areas of testing:
  1. 1.

    Stubbing

     
  2. 2.

    Mocking

     

You are going to learn these techniques using Jasmine (although you will come back when you will be doing tests using Ruby).

With stubbing, you are going to specify how a method should behave when another method returns specific values (Figure 2-1).
../images/497830_1_En_2_Chapter/497830_1_En_2_Fig1_HTML.jpg
Figure 2-1

Stubbing Example

With mocking, you are going to specify which methods are expected to be called (Figure 2-2).
Figure 2-2

Specifying Which ...

Get Practical Test Automation: Learn to Use Jasmine, RSpec, and Cucumber Effectively for Your TDD and BDD now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.