firebase / firebase-functions-test

MIT License
232 stars 48 forks source link

functions.logger missing #81

Closed epall closed 3 years ago

epall commented 3 years ago

It appears that functions.logger, documented at https://firebase.google.com/docs/functions/writing-and-viewing-logs, is missing from firebase-functions-test.

Version info

firebase-functions-test: 0.1.7

firebase-functions: 3.3.0

firebase-admin: 8.9.1

Test case

/* index.js */

const functions = require('firebase-functions');
exports.myFunc = functions
  .firestore
  .document('quotes/{quoteId}')
  .onUpdate(async ({before, after}) => {
    functions.logger.info("Hello, world!");
}

/* index.test.js */
const myFunctions = require('../index');
const test = require('firebase-functions-test')(firebaseConfig, 'XXX');

describe("myFunc", () => {
  const myFunc = test.wrap(myFunctions.myFunc);
  myFunc();
});

Steps to reproduce

  1. Run index.test.js

Expected behavior

Nothing happens, it executes successfully.

Actual behavior

TypeError: Cannot read property 'info' of undefined
    at Function.exports.sendReadyNotification.functions.firestore.document.onUpdate [as run] (index.js:253:24)
epall commented 3 years ago

Turns out I had an outdated version of firebase-functions that was missing logger.