-
Notifications
You must be signed in to change notification settings - Fork 892
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
transaction.get
does not match firestore-admin in @firebase/testing
#2535
Comments
Looking at the error and reading the docs on transactions does expect the argument to be a But the admin SDK does allow passing a collection reference like this. |
I wish we were given the ability to stub them so it doesn't mess with the typescript typings when we use them on the same code |
I'm having a similar issue but with the
|
Are there any updates from anybody working on this? Is it being looked into? |
@ChromeQ / @Elyx0 / @zv3 I don't believe we have any short term plans to fix this issue. Unfortunately, this is an inherit issue in the way our APIs are designed and bundle in the testing SDK. That being said, I assigned this to @yuchenshi to see if he has more insight. |
@schmidt-sebastian is right about the situation with @firebase/testing. However, for your case we recommend just using the Node.js Admin SDK with the |
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
With an app running on cloud functions the firestore is accessed via
firebase-admin
initializeApp.For testing purposes I import
@firebase/testing
and initializeAdminApp to create a firestore.In production code the code below works, but in testing it throws an error:
> (node:23599) UnhandledPromiseRejectionWarning: FirebaseError: Function Transaction.get() requires its first argument to be a DocumentReference, but it was: a custom CollectionReference object
Relevant Code:
Here is a simple snippet of example;
Now run this code with
npx firebase emulators:start --only functions
to see it working as expected.Run again with
NODE_ENV=test npx firebase emulators:start --only functions
to see the errorBecause @firebase/testing uses the firebase (client) package to emulate the admin SDK the Transaction methods are not the same as in the admin SDK. This makes writing my tests obsolete as I cannot replicate production process in my test env.
The text was updated successfully, but these errors were encountered: