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 ...
Get Jasmine Cookbook 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.