O'Reilly logo

Test-Driven JavaScript Development by Harmeet Singh, Hetal Prajapati, Ravi Kumar Gupta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Nesting suites

As a project matures, the unit testing code grows huge and it's difficult to maintain. In such cases, it's good to use nested suites. Consider an example of a company, where employees are classified into several departments such as admin, finance, HR, delivery, presales, and sales. While there can be a common set of specs that apply to all employees, each department may also need some specs for department-specific features. Desk allocation can be task related to admin, while annual prize distribution can be a part of HR. Now all these specs can be grouped into suites, and all these suites can be clubbed into one suite for the whole company. We can nest suites by placing a describe block into another describe:

describe("Testing Company ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required