How to Only Run Tests in a Single Mocha "describe()" Block?

To run all tests described in a single describe() block, you can simply call the .only() method on describe in the following way:

describe.only('...', function () {
  // only tests in this block will run...

Similarly, you can call only() on it as well if you wish to run a single test.

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.