Closed AgungLaksana closed 2 years ago
I finally find the solution,
for unit test security rules, I have to change from
import * as admin from "firebase-admin";
const coordinate = new admin.firestore.GeoPoint(latitude, longitude);
to be
import { GeoPoint } from "firebase/firestore"
const coordinate = new GeoPoint(latitude,longitude);
the web and admin SDKs have separate GeoPoint classes that are not interoperable with each other.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:
so previously I have the same exact problem, but the solution is no longer valid for the latest
@firebase/rules-unit-testing
here is the previous related issue: https://github.com/firebase/firebase-js-sdk/issues/4723[REQUIRED] Describe your environment
I am using
Operating System version: macOS v12.5 Firebase Product: rules-unit-testing; firestore Node 16 firebase-admin": "^9.11.0" firebase-functions": "^3.15.5" @firebase/rules-unit-testing": "^2.0.4" firebase-tools 10.9.2
[REQUIRED] Describe the problem
Steps to reproduce:
I am trying to perform unit testing of my security rules using library @firebase/rules-unit-testing. when I try to create a document on security rules unit test, it will always have error if the document has property which is a Firestore Geopoint.
new admin.firestore.GeoPoint(this.latitude, this.longitude);
the error is:
from my previous issue, it is said that the root cause was
and the suggested solution was to use the Geopoint from
@firebase/rules-unit-testing
dependency like belowRelevant Code:
the problem is, I can no longer find
firebase.firestore.GeoPoint
on the latest@firebase/rules-unit-testing
dependency. so how to get Geopoint that can be used on my security rules unit testing?