Last active
March 31, 2020 03:18
-
-
Save jamescrowley/d6f6468a9bfc5c4982d5a4838097acc2 to your computer and use it in GitHub Desktop.
Repro for Jest issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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"}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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