-
Notifications
You must be signed in to change notification settings - Fork 970
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
Getting metadata from plugin failed with error: invalid_grant #3098
Comments
Found an interesting thread on Reddit where a person wants to connect to prod but is getting this error. Is that what's happening here? Somehow my code is trying to reach out to the production Firestore? |
When running your test with However, since you are directly calling the functions code via mocha, those environment variables aren't set, and your code is connecting to production. The error is generally related to the gcloud cli (see firebase/firebase-functions#121), and should go away by talking to the emulators instead. You can either run the test by using |
@kmcnellis can you point me to an example of this? I have no idea what |
Ah hah! So this kind of makes sense. You're saying because the functions are exposed locally (localhost:number), I can tweak my tests to just use a node-based http library to just hit the endpoints, and then test the outcome of those functions. Is this documented anywhere officially? I feel like the documentation around local testing (now that we have emulators) hasn't quite kept up with the speed of development (not a terrible problem!). Repos like the quickstart-testing are great, but we need more examples of how to perform these common actions with emulators. @samtstern do you think that quickstart repo (the simple HTTP function) could be altered/added-to to show this strategy that @kmcnellis is suggesting? i.e. would that be the right place to document this approach? |
For other people who get the
and
|
I opened firebase/quickstart-testing#97 to track improving the documentation! Closing this here as I don't think there's a CLI bug. |
[REQUIRED] Environment info
firebase-tools: 9.2.2
Platform: Windows
[REQUIRED] Test case
Trying to test an HTTP onRequest function that writes to the emulated Firestore.
[REQUIRED] Steps to reproduce
index.ts
testWrite.ts
functions.spec.js
[REQUIRED] Expected behavior
Currently this test passes because the assertion evaluates to true, but I'd also expect the firestore write to succeed as well.
[REQUIRED] Actual behavior
cross-env GCLOUD_PROJECT=fakeproject firebase emulators:start --project=fakeproject --only=firestore,functions,auth
tsc watch
mocha functions.spec.js --exit
This is the error output (from the try/catch block above):
Side Note
This would be a great quickstart testing example to include in https://github.com/firebase/quickstart-testing
UPDATE:
When running
firebase emulators:exec 'npm run test'
I am not getting these errors. I can't discern what the difference is when running emulators using this command vs.firebase emulators:start
The text was updated successfully, but these errors were encountered: