[REQUIRED] Describe your environment
- Operating System version: Windows 10
- Browser version: Chrome 81.0.4044.138 64 bit
- Firebase SDK version: 8.4.0
- Firebase Product: firestore
[REQUIRED] Describe the problem
When using firebase/testing to run local tests, I encounter the following problem:
when I attempt to store document containing timestamp field I get an error:
"Function DocumentReference.set() called with invalid data. Unsupported field value: a custom object (found in field encrypted_data.registrationDate)"
encrypted_data.registrationDate is the field of type Timestamp.
Steps to reproduce:
Create db connection to local simulators using '@firebase/testing'
Create timestamp value using FirebaseFirestore.Timestamp from 'firebase-admin';
Store document with timestamp value.
Same code works when using db connection from 'firebase-admin', both with local simulators and with cloud production environment.
Non-timestamp fields are stored normally.
Relevant Code:
The db connection and timestamps are obtained as follows:
import * as firebaseTest from '@firebase/testing'
import admin from 'firebase-admin';
export class ServiceDirectoryTest {
////other stuff
private async initializeFirebase() {
this.firebaseApp = firebaseTest.initializeAdminApp({ projectId: this.projectId })
this.prodAdminApp = admin.initializeApp()
}
db(): FirebaseFirestore.Firestore {
let db :any = this.firebaseApp.firestore()
//let db = this.prodAdminApp.firestore()
return db;
}
now(): FirebaseFirestore.Timestamp {
return admin.firestore.Timestamp.now()
}
}
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
When using firebase/testing to run local tests, I encounter the following problem:
when I attempt to store document containing timestamp field I get an error:
"Function DocumentReference.set() called with invalid data. Unsupported field value: a custom object (found in field encrypted_data.registrationDate)"
encrypted_data.registrationDate is the field of type Timestamp.
Steps to reproduce:
Create db connection to local simulators using '@firebase/testing'
Create timestamp value using FirebaseFirestore.Timestamp from 'firebase-admin';
Store document with timestamp value.
Same code works when using db connection from 'firebase-admin', both with local simulators and with cloud production environment.
Non-timestamp fields are stored normally.
Relevant Code:
The db connection and timestamps are obtained as follows: