Run only ONE test with Jest

Jest parallelizes test runs and it doesn’t know upfront which tests it
should run and which it shouldn’t run.
This means when you use “fit”, it will only run one test in that file.
But it still runs all other test files in your project
.

fit, fdescribe and it.only, describe.only have the same purpose: skip other tests and run only me.

Source: https://github.com/facebook/jest/issues/698#issuecomment-177673281


Use the Jest filtering mechanism. When you run your tests like,

jest --config=jest.config.json --watch

you can filter tests by a testname or filename. Just follow the instructions in the terminal.

Enter image description here

Press p, and then type a filename.

Enter image description here

Then you can use describe.only and it.only which will skip all other tests from the filtered, tested file.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)