jest: `.only` does not work in jasmine1 and not supported in jasmine2 runners
Steps to reproduce:
git clon https://github.com/facebook/jest.git
npm i
- change some test
it
toit.only
npm test
Result: jasmine1 runner
149 tests passed (149 total in 20 test suites, run time 4.652s)
jasmine2 runner
- TypeError: it.only is not a function
Please fix it as it is very difficult to develop tests without it!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (7 by maintainers)
I believe
describe.only
,fdescribe
,it.only
, andfit
don’t work!!! I know there’re 2 solutions to run a specific test such as test.only instead of it.only or running “jest -t TEST_NAME”. However, I need to use the above functions to run focused tests. Am I missing a flag while running jest?I think we should go a familiar way. If I develop test it should be enough to mark it as
.only
orfit
or whatever to run and debug exclusively. From the jest side as I understand currently it gets spec file and instantly passes it to the runner. In developer mode we can first concat all specs into single bundle and then pass it to runner. In that case jasmine’s built-in.only
mechanism will do the job. Performance is not the issue during single test development.Same issue here.
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
should only be used for debugging purposes, so I recommend invoking jest withjest MyTest.js
, which will only run one file and the one test within it.Hey! This is an intentional API change. Jasmine 2 has
fit
andfdescribe
, meaningfocused it
andfocused describe
instead.