Skip to content
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

When using factory with jest and mongoose, process doesn't end #152

Open
charleswvs opened this issue Apr 28, 2020 · 1 comment
Open

When using factory with jest and mongoose, process doesn't end #152

charleswvs opened this issue Apr 28, 2020 · 1 comment

Comments

@charleswvs
Copy link

I am having an issue using Factory girl with Jest.
When I create a factory, like this one:
const person = await factory.create('Person');

Inside a test, I get the following warn on Jest:

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

And my process never ends, I am using the option jest --forceExit as a way around, but it is not quite right to do that

@7hibault
Copy link

7hibault commented Jul 2, 2020

In my experience, this is usually due to an unclosed db connexion, which means you're probably missing something like that

  afterAll(async () => {
    await connection.close();
    await db.close();
  });

https://jestjs.io/docs/en/mongodb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants