Book Image

Jasmine Cookbook

By : Munish Kumar
Book Image

Jasmine Cookbook

By: Munish Kumar

Overview of this book

Table of Contents (16 chapters)
Jasmine Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Defining nested suites to write more meaningful specs


Sometimes, we need to refactor Jasmine specs by defining a suite or suites within a suite (that is, nested suites) to make it more granular and readable. This helps all stakeholders to understand the functionality from a holistic perspective. Moreover, you can easily identify and map the failing spec(s) with an exact piece of code. In this recipe, you will learn to design specs with nested suites.

Note

In Jasmine, we can define suites using the describe global function. This function accepts two parameters (string and function()). The string parameter is for naming the collection of specs and function() is a block of code that implements the suite.

Getting ready

You will learn this recipe with the help of a previous recipe in this chapter. For more information, refer to the Designing the Jasmine test for existing code using TDD and BDD recipe.

To understand when and how to define nested test suites to write more meaningful specs, let's consider...