jest: --detectOpenHandles not showing any message even test not finished completely.
I am going to build Mongodb environment in typescript project. I referenced this page https://jestjs.io/docs/en/mongodb and sample project https://github.com/vladgolubev/jest-mongodb
When I run jest
in my project, it pass test ( I setup very simple test to test only mongodb environment) but it doesn’t finish with success.
It recommend me to use --detectOpenHandles
to check non stopped asynchronous operations.
But when I run jest with this flag, jest --detectOpenHandles
it finish successfully without showing what operations are not stopped.
I tried many times, and it work same as I mentioned above.
Thanks
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 16
- Comments: 25 (6 by maintainers)
We have an issue template that requests reproduction steps - this report is missing that. Happy to reopen if one is provided
Running with
jest --forceExit --detectOpenHandles
seems to work as expected. But it seems like a hack…@SimenB I have a repro for this:
to run the db I’m doing
docker-compose up
with thisdocker-compose.yaml
:dependencies
"slonik": "^16.19.5", "jest": "^24.8.0"
When running with
--detectOpenHandles
it just hangs after all tests pass, but doesn’t report anything.Issue in slonik: https://github.com/gajus/slonik/issues/63
edit: adding
afterAll(() => new Promise(r => setTimeout(r, 0)))
fixes this for me (jest exits after tests). Not sure why that would be, but it seems like a bug.THANKS! After three hours! This was exactly what I was looking for!
@SimenB as requested: https://github.com/mmkal/jest-6937-repro
Requires
yarn
anddocker-compose
:More details/a workaround in readme which might help to figure out the root-cause.
@SimenB I can confirm the issue @mmkal is showcasing.
Experiencing the same issue here. Unfortunately, the workaround does not work for me. I have to use
--forceExit
A proper reproduction we can pull down and run. I can almost guarantee anything that’s not
git clone && yarn && yarn test
(possibly with adocker run
before test if it needs to connect to something, and npm is of course fine) will not be very helpful.https://github.com/facebook/jest/issues/6937#issuecomment-500886506 packaged up in a repository might work. https://github.com/facebook/jest/issues/6937#issuecomment-562861333 doesn’t reproduce for me.
Note that I have an open PR that improves this (#9532), however it makes certain simpler caser worse. Need to figure out the correct balance. Probably some sort of heading saying which were collected in case it helps track down others. So more false positives, but also higher chance of not missing the ones that are real
jest --forceExit
seems to work fine for me but also seems like a hack while I ignore the real problem.