Open jamalsoueidan opened 5 years ago
For those experiencing this when working with Firebase, you likely need to call testEnv.cleanup();
let testEnv;
beforeAll(async () => {
// Silence expected rules rejections from Firestore SDK. Unexpected rejections
// will still bubble up and will be thrown as an error (failing the tests).
setLogLevel("error");
testEnv = await initializeTestEnvironment({
projectId: projectId,
firestore: {
rules: readFileSync("firestore.rules", "utf8"),
host: "127.0.0.1",
port: 8080,
},
});
});
afterAll(async () => {
await testEnv.cleanup();
})
I'm getting this message every time i'm using any libraries that depend on promises.
🐛 Bug Report
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.To Reproduce
I have a function that need to make a request to external api, and in the same method just save in the database without waiting for a response.
I don't want to wait until the saving process is done, but i'm forced to change the behaviour of my application to get it tested through jest., or i need to close the connection, stop the server for my code to work.
Expected behavior
Excecpted jest to stop and return to my console.
Link to repl or repo (highly encouraged)
line49 and line50
I had to make those changes to get jest working with my api server and mongodb. https://github.com/jamalsoueidan/giv-et-tilbud/commit/d8f326b6294f88d1f12136042d4adfdc83328201
Run
npx envinfo --preset jest