I'm using firebase-admin 8.6.0 and firebase-functions-test 0.1.6 which has support for Firestore Timestamps in testing (as of 0.1.5 https://github.com/firebase/firebase-functions-test/releases) but am still receiving an error message when trying to use them with test.firestore.makeDocumentSnapshot
.
Can someone help me understand the error in my implementation?
import * as admin from 'firebase-admin';
admin.initializeApp();
const db = admin.firestore();
const settings = { timestampsInSnapshots: true};
db.settings(settings);
const timestamp = admin.firestore.FieldValue.serverTimestamp();
const testingTimestamp1 = admin.firestore.Timestamp.now();
const testingTimestamp2 = admin.firestore.Timestamp.fromDate(new Date);
import * as TestFunctions from 'firebase-functions-test';
const firebaseConfig = {
databaseURL: 'https://...HIDDEN...',
projectId: '...HIDDEN...',
storageBucket: '...HIDDEN...appspot.com',
}
const test = TestFunctions(firebaseConfig, 'service-account-dev.json');
const data({
timestamp,
testingTimestamp1,
testingTimestamp2,
});
const snap = test.firestore.makeDocumentSnapshot(data, path);
const wrapped = test.wrap(processImport);
await wrapped(snap, {params: testParams});
I can't get any of the three timestamp options to work. The latter one I tried learning from @the0rem in https://github.com/firebase/firebase-functions-test/pull/28 but to no avail. I always receive this error:
Cannot encode [object Object]to a Firestore Value. Local testing does not yet support Firestore geo points.`
test
? Did you miss showing an import somewhere?