-
Notifications
You must be signed in to change notification settings - Fork 988
Open
Labels
Description
[REQUIRED] Describe your environment
- Operating System version: macOS Big Sur (Version 11.2.3)
- Browser version: N/A
- Firebase SDK version: 9.7.0
- Firebase Product: firestore
[REQUIRED] Describe the problem
When using @firebase/rules-unit-testing and jest the tests will not exit cleanly and you will get the warning:
Jest did not exit one second after the test run has completed.. Deleting the apps after the tests have finished does not help.
Steps to reproduce:
- Run the firestore emulator using
firebase emulators:start - Make sure jest is installed (I'm using version 26.6.3). In my case I'm also using
ts-jestand@types/jestto write my tests using typescript. - Create a basic test that attempts to get a document from the Firestore DB
- Run the tests using the
jestcommand and you will get the following warning:
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.
--detectOpenHandles does not help at all, it just hangs instead of exiting.
I tried to delete every app after each test in order to close any asynchronous calls but that also didn't help.
Relevant Code:
import * as firebase from "@firebase/rules-unit-testing";
describe("Security rules", () => {
afterEach(async () => {
await Promise.all(firebase.apps().map((app) => app.delete()));
});
it("Can read stuff", async () => {
const app = firebase.initializeTestApp({ projectId: "whatever" });
const db = app.firestore();
const testDoc = db.collection("private").doc("a_doc");
await firebase.assertFails(testDoc.get());
});
});giacomoran, phlebotinum, AndreasKl and KeunwooParkdavetayls, stvreumi, giacomoran, ComplexRalex, phlebotinum and 1 more