Categories
JavaScript Answers

How to run only one test with Jest?

Spread the love

Sometimes, we want to run only one test with Jest.

In this article, we’ll look at how to run only one test with Jest.

How to run only one test with Jest?

To run only one test with Jest, we can use fit, fdescribe, it.only, or describe.only and specify the test file to run.

We edit the test file to have fit, fdescribe, it.only, or describe.only to specify that we only run the test created with those functions.

And then we run

jest test.js

to run the test file with the fit, fdescribe, it.only, or describe.only calls in it.

We replace test.js with the path of the test file.

Conclusion

To run only one test with Jest, we can use fit, fdescribe, it.only, or describe.only and specify the test file to run.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *