-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connecting in globalSetup doesn't work #297
Comments
I am having this same issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I have multiple test files that use Mongo. I would like to connect only once (in the
globalSetup.ts
), and disconnect only once, after every test is done, onglobalTeardown.ts
.I tried following the steps from #212
But it doesn't seem to work.
This is my
globalSetup.ts
. It seems to be working fine, theMONGO_URL
is always set../server/tests/__scripts__/globalSetup.ts
However, in all of my tests, Mongo is just unresponsive. Jest throws the "Exceeded timeout of 5000ms for a hook" error.
It does work, however, if I connect inside the test file using
beforeAll
:./server/tests/repositories/notificationRepository.test.ts
This is my config:
./server/tests/jest.base.config.js
Am I missing something obvious? Is there a way I can connect to Mongo inside
globalSetup
and use the connection throughout my test files?Thanks!
The text was updated successfully, but these errors were encountered: