How to run only one test with Jest?

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.