firebase-functions-test
firebase-functions-test copied to clipboard
makeDocumentSnapshot: TypeError: firestoreService.snapshot_ is not a function
I get the following error when trying to use makeDocumentSnapshot
: TypeError: firestoreService.snapshot_ is not a function
It seems that it has to do with the following line: https://github.com/firebase/firebase-functions-test/blob/2574781e959ab019c3e3823a59c26f9b30d65a6c/src/providers/firestore.ts#L83
My code is as follows:
import FunctionsTest from 'firebase-functions-test';
import onUserWritten from '../onUserWritten.function';
const test = FunctionsTest();
describe('onUserWritten', () => {
it('should do stuff', async () => {
const wrapped = test.wrap(onUserWritten);
const beforeSnap = test.firestore.makeDocumentSnapshot(
{
id: 'testUser',
email: '[email protected]',
},
'/users/testUser',
);
...
First of, apologies for the very delayed response to this - this repo was unmaintained for a bit, but we are trying to bring it back to life. It looks like the root cause here is that we rely on snapshot_ https://github.com/googleapis/nodejs-firestore/blob/master/dev/src/index.ts#L825, which is private. I'm going to chat with my team about how we should fix this, and try to rework this to use public methods.
Any updates on this issue?
@joehan any news on this issue? Following the officiel doc we need to use the makeDocumentSnapshot
.
Maybe @TheIronDev can help as he is the most recent contributors?
The issue happens with "firebase-functions-test": "^2.0.2",
I can certainly take a look.
Giving a heads up, it might be a minute while I sort through previous history.
@tettoffensive || @HugoGresse
Do either of you have a repo that can reproduce this? I attempted for a while this morning but was not able to reproduce. Might be due to my node version + installed modules.
@TheIronDev I do not. I reported this a couple years ago. But it seems like snapshot_
is still not an exposed method. So I'm not sure why makeDocumentSnapshot would work for you.
I've made a small repro : https://github.com/HugoGresse/84-fb-functions-makesnapshot-repro BUT, the issue is caused by my stub for firestore... which is 🤦 only a PEBKAC issue
@HugoGresse - It wasn't a PEBKAC issue until recently :)
@tettoffensive -
Digging deeper, it looks like this issue was introduced in https://github.com/googleapis/nodejs-firestore/pull/1570, when a bunch of @internal
were added.
However,
https://github.com/googleapis/nodejs-firestore/pull/1688 added @private
annotations to a handful of the snapshot_
overload signatures.
I believe this makes most of the overloads accessible, with the exception of the first signature that does contain the @internal
here
I'll try to open up a cl to change the @internal
to @private
, stay tuned!
@TheIronDev Good find. I think when I initially reported it I was working with the firebase-admin
package, which I'm not even sure has snapshot_
. I'll have to dig since I can't really remember if that's the case or not.
https://github.com/googleapis/nodejs-firestore/pull/1728 got merged, which resolves this issue! 🎉