Why is it not recommended to put tests in a describe block?

Viewed 191

According to React documentation:

You may optionally wrap them in describe() blocks for logical grouping but this is neither required nor recommended.

I wonder why putting it blocks in describe blocks is not recommended?

1 Answers

I would like to know the author opinion on the subject, but I believe it is because describe() allows you to group tests within the same file, and to nest them.

Nesting is dangerous, because it’s easy to take it too far. When you have three or more levels of nesting, and each level runs setup code in its own lifecycle methods (beforeAll, beforeEach, afterAll, afterEach), you have to look at many places throughout the file just to understand what’s going on in one test.

I believe breaking down the tests group in different files is better than abusing describe().

As a wise man once said: "with great power comes great responsibility"

Related