Closed AgungLaksana closed 3 years ago
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
@AgungLaksana Thanks for writing in! The issue here is that the web and admin SDKs have separate GeoPoint classes that are not interoperable with each other. If you're using the web SDK with initializeTestApp()
, you'll have to the GeoPoint class from the web SDK
. In your case, you'll need to use the web SDK's GeoPoint class:
import * as firebase from "@firebase/rules-unit-testing";
const event = new Event("event title", new firebase.firestore.GeoPoint(-6.931980, 107.559540))
const eventData = { ...event};
const promise = ref.set(eventData);
await firebase.assertSucceeds(promise); //
For more context, see #3910 and #4129. I'm going to mark this issue as closed since this is WAI, but feel free to comment if you have other questions!
I am using
I am trying to perform unit testing of my security rules using library @firebase/rules-unit-testing. when I try to create a document using test app firestore like my code below, it will always have error if it has property which is a Geopoint.
the error is:
FirebaseError: Function DocumentReference.set() called with invalid data. Unsupported field value: a custom object (found in field coordinate in document events/test-580f807-454d-44b3-bd3d-8df40ca1d16e)
the custom object is Geopoint, because I have a field called coordinate which is a Geopoint. but I need to test my security rules, I have to test this rule:
request.resource.data.coordinate is latlng
how to test if it is latlng or not If I can't create document with Geopoint?
i can create a document that has Geopoint as its field using
firebase.initializeAdminApp().firestore()
(admin), but it will always has an error if I create it usingfirebase.initializeTestApp().firestore()