You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dimroc@DimitrisMBP2018: functions (chores/convert-rtdb-to-firestore)$ jest src/jseasyrepro.test.js
(node:74293) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
FAIL src/jseasyrepro.test.js
firebasetesting broken
✕ when invoking firestore() (10ms)
● firebasetesting broken › when invoking firestore()
TypeError: app.firestore is not a function
3 | const createApp = () => {
4 | console.log('--- init admin app')
> 5 | const rval = firebase.initializeAdminApp({projectId: 'projectId'})
| ^
6 | console.log('--- FINISHED init admin app ', rval)
7 | return rval
8 | }
at initializeApp (node_modules/@firebase/testing/src/api/index.ts:133:9)
at Object.initializeAdminApp (node_modules/@firebase/testing/src/api/index.ts:103:10)
at createApp (src/jseasyrepro.test.js:5:25)
at Object.it (src/jseasyrepro.test.js:12:17)
console.log src/jseasyrepro.test.js:4
--- init admin app
originally found in typescript
import*asfirebasefrom"@firebase/testing"// tried all sorts of import side effects but shouldn't be needed// because we're server side and the code is invoked inside firebase/testing.// const Firestore = require('@google-cloud/firestore')// import `firebase/firestore`constcreateApp=()=>{console.log('--- init admin app')constrval=firebase.initializeAdminApp({projectId: 'projectId'})console.log('--- FINISHED init admin app ',rval)returnrval}describe("firebasetesting broken",()=>{it("when invoking firestore()",()=>{constapp=createApp()constfs=app.firestore()expect(1).toBe(1)})})
I tried to reproduce this by creating a fresh npm project, adding 2 files:
Your top example file (with require), naming it index.test.js
Your package.json
I did a yarn install and then ran jest, and the test passed. I had it console.log "fs" right before the "expect" line and it logged what seems to be a complete Firestore object. Am I missing a step?
Just wanted to leave a comment for anyone encountering this issue (As I just had).
The problem might be fixed by upgrading your node version, and re-installing the packages.
First I tried installing with npm, didn't get any error, but got this error.
Then when I tried running yarn install, I got some errors and info messages about my node version. As soon as I updated to the latest version of node 8, I could install dependencies with both npm and yarn, and the test would run successful.
Describe your environment
Describe the problem
Attempting to test cloud functions offline: https://firebase.google.com/docs/functions/unit-testing#initializing, but against the firestore local emulator. Narrowed down the issue to being
firebase/testing
being unable to invokefirestore()
Steps to reproduce:
npm install @firebase/testing --saveDev
firebase.initializeAdminApp({projectId})
app.firestore()
Should return an instance of firestore but throws.
Relevant Code:
https://stackblitz.com/fork/firebase-issue-sandbox
Callstack
originally found in typescript
tsconfig.json
package.json
The text was updated successfully, but these errors were encountered: