Skip to content

Instantly share code, notes, and snippets.

@jamescrowley
Last active March 31, 2020 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamescrowley/d6f6468a9bfc5c4982d5a4838097acc2 to your computer and use it in GitHub Desktop.
Save jamescrowley/d6f6468a9bfc5c4982d5a4838097acc2 to your computer and use it in GitHub Desktop.
Repro for Jest issue
'use strict';
const firebase = require("firebase-admin");
const serviceAccount = require('./serviceAccountKey.json');
firebase.initializeApp({
credential: firebase.credential.cert(serviceAccount),
databaseURL: `https://${serviceAccount.project_id}.firebaseio.com`
});
exports.handler = async () => {
await firebase
.database()
.ref(`/someRef`)
.set({some:"data"});
}
const pushToFirebase = require("./main.js");
test("can push message", async () => {
await pushToFirebase.handler();
expect(true).toEqual(true);
// this will hang - need to call firebase.database().goOffline() to close all handles
});
{
"name": "pushtofirebase",
"version": "1.0.0",
"main": "pushToFirebase.js",
"dependencies": {
"firebase-admin": "^8.10.0"
},
"devDependencies": {
"jest": "^25.2.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment