Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
The `describe` Block | Using a Test Automation Framework
Introduction to QA Automation Testing
course content

Зміст курсу

Introduction to QA Automation Testing

Introduction to QA Automation Testing

1. Introduction to Automation Testing
2. Using a Test Automation Framework
3. Browser Automation with Selenium
4. Intro to Intermediate Automation Testing

bookThe `describe` Block

Summary

Sometimes, we might have many tests in a single Test Script, which can become unorganized and hard to manage. For an example, lets create a new file called math.js with a Math class in it:

This class contains four methods and we write multiple test cases for each method. Since the test cases are related to a single class, therefore, conventionally we would store all the test cases related to it in a single file called math.test.js:

However, as you might notice, this can become confusing and unorganized since it contains test cases for multiple different methods. If we run the above tests using the verbose flag, you will see that the tests are all piled up in a sequence with no distinction.

In such situations it is imperative to group together the related test cases using describe blocks:

Using the above syntax, we can group together the test cases of each method:

Now the code looks more organized, and if we run the tests with the verbose flag, you will notice that the output is more hierarchical as well, making it easier to see the different test cases for each method.

It is also important to note that we can nest describe blocks to further organize the hierarchy of Test Cases:

The describe blocks also help in defining the scope of each Test Case. We will see some uses of the scopes of test cases in later topics.

Apart from that, since we typically group together test cases in a describe block, each describe block is referred to as a Test Suite in this case. It is important to note that, in other programming languages, a whole Test Script is typically referred to as a Test Suite.

What can be the describe block used for in Jest? (Select all that Apply)

What can be the describe block used for in Jest? (Select all that Apply)

Виберіть кілька правильних відповідей

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 6
We're sorry to hear that something went wrong. What happened?
some-alt