I’m trying run unit tests against for my Cloud Functions through the emulator. However, when I call a wrapped onDocumentWritten
function in my unit test, it never receives the proper input data – the value for event.data.after.data()
is always the default placeholder { aString: 'foo', anObject: { a: 'qux', b: 'faz' }, aNumber: 7 }
.
Any idea why this is happening, and what I can do to fix it?
The code in my test function is as follows:
const path = `items/${generateTempId()}`
const data = {name: "MyTest"}
const s = await db.doc(path).set(data)
const after = await wrapped(s)
Also, for the code to instantiate the db variable:
const app = admin.initializeApp({
projectId: <projectId>,
credential: admin.credential.applicationDefault()
})
const db = app.firestore()