Very simple, I want to run just one test with Jest.
I put it.only
or describe.only
but it still runs a whole lot of tests.
I think it runs all the tests since my last commit, but it shouldn't have this behavior with the only
flag explicitly set, right?
What causes this behavior and how to run a single test?
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 still run all other test files in your project.
fit
, fdescribe
and it.only
, describe.only
have the same purpose, skip other tests, run only me.
Source: https://github.com/facebook/jest/issues/698#issuecomment-177673281
Use 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 instructions in the terminal
Press p
, then type a filename
Then you can use describe.only
and it.only
which will skip all other tests from filtered, tested file.