Closed bradleymackey closed 4 years ago
Apologies for the confusion, but the firebase-admin
and @firebase/testing
types are not meant to be compatible. See discussion and how to adjust your tests in a prior issue on this topic.
The TL;DR on this is:
@firebase/testing
is intended to be used for testing security rules onlyThe underlying problem is that @firebase/testing
is based on the Web SDK, but you're exercising the Admin SDK. Though these interfaces look similar they're actually different implementations and have incompatible types.
Thanks for the info, this is unfortunate that this is the case though. It makes testing security rules with existing TypeScript data models a tad more difficult.
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
Two seemingly identical GeoPoint types are provided from
firebase-admin
(for production) and@firebase/testing
(for testing). The two GeoPoints are not compatible - we can't put afirebase-admin
GeoPoint in a@firebase/testing
database and vice versa.Trying to place a
firebase-admin
GeoPoint into a test Firestore database created with@firebase/testing
results in the error:A bit of manual type introspection (with
util.inspect
) reveals that the internal structure of these GeoPoint types differs, but ideally these would be compatible. For example, consider a GeoPoint at latitude 10, longitude 10.@firebase/testing
Geopoint:firebase-admin
GeoPoint:This is an issue because it means that existing models and functions that we would like to test (that only accept
firebase-admin
GeoPoints) will fail when we try to add them to the database.Steps to reproduce:
Create a test Firestore database with
@firebase/testing
.Try to insert a GeoPoint created from
firebase-admin
into the test database. The operation fails with the error message provided above.Relevant Code: