Skip to content

event.data.val() is null in unit tests #137

@zgosalvez

Description

@zgosalvez

Version info

firebase-functions: 0.7.3
firebase-tools: 3.15.3
firebase-admin: 5.5.1

Test case

//
// In unit test
//
// ...
user = {
  firstName: 'me'
};
event = {
  params: {
    userId: 'user-id',
  },
  data: new functions.database.DeltaSnapshot(null, null, null, user)
};
console.log(event.data.val()); // 1st log
await myFunctions.onUserWrite(event);
// ...
//
// In onUserWrite
//
export.onUserWrite = functions.database.ref('/users/userId').onWrite(async event => {
  // ...
  console.log(event.data.val()); // 2nd log
  // ...
);

Were you able to successfully deploy your functions?

No, since unit tests fail, but manually deploying (skipping unit tests) shows no issues.

Expected behavior

1st and 2nd logs, should both show user object.

Actual behavior

  • 1st log shows null
  • 2nd log shows null

Reverting back to firebase-functions: 0.7.2 fixes the issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions