React Native Jest doesnt exit, and show the actual library as the cause of the problem

Viewed 97

Im implementing tests framework (jest) in react native with testing-library/react-native, on an existing project. When I run their example (intro) the app give the infamous error:

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

when I try to check it with the flag --detectOpenHandles, it shows that the library itself is the problem. enter image description here

I have no config file for jest. RN - 66.4 jest - 28.1.0 babel-jest - 26.6.3 jest-circus - 26.6.3 eslint-plugin-jest - 26.1.1

1 Answers

My problem was solved by this code:

beforeAll(done => {
  done()
})

afterAll(done => {
  // Closing the DB connection allows Jest to exit successfully.
  mongoose.connection.close()
  done()
})
Related