-
Notifications
You must be signed in to change notification settings - Fork 894
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
Terminating node process when using firebase within mocha tests #1487
Comments
I found a few problems with this issue:
|
Thanks for providing the repro! What works for me is moving the initialization logic to beforeEach function. I don't exactly know how mocha works internally, but my guess is you need to provide the initialization code in the mocha context, and it does some cleanup for you. |
@Feiyang1 Thanks for looking into it and for providing a solid workaround - I really appreciate that. A somewhat related issue, in case somebody stumbles upon this: If you use describe('', () => {
let firebaseApp;
before(async () => {
firebaseApp = await firebase.initializeApp(config);
return firebaseApp.auth().signInWithEmailAndPassword(mail, password);
});
after(() => {
firebaseApp.auth().signOut();
firebaseApp.delete();
});
it('....', async () => {
});
}); @Feiyang1 would it make sense to perform things like signing out when you delete an app? |
I'm glad it worked out for you. Can you please open a new issue regarding the signOut, so we can track it properly? |
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
Steps to reproduce:
I tried to connect to a firebase database within a mocha test, but even though I deleted the app afterwards (or even within the test) the node process is not terminating. No combination of
app().delete()
ordatabase().goOffline()
did work in this case.The result is that the test runner is not able to terminate the process which means it can not be really be used within a CI environment.
It may be related to #859 but since that issue was related to auth it's possibly a different problem.
Relevant Code:
sut.js
sut.spec.js
Run
eslint sut.spec.js
afterwards to invoke the tests. Also see https://github.com/klausbayrhammer/firebase-mocha-pending-connection to reproduce the problemThe text was updated successfully, but these errors were encountered: