question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating to latest Firebase SDK to causes tests to fail in quickstart/uppercase

See original GitHub issue

Steps to reproduce

  1. Upgrade libraries to the latest Firebase SDK in /quickstarts/uppercase/functions/package.json
...
  "dependencies": {
    "firebase-admin": "5.4.3",
    "firebase-functions": "0.7.1"
  },
...
  1. Run npm install
  2. Run npm run test

Expected behavior

Tests should pass

Actual behavior

The tests fail with the following error message. As far as I can tell, this was introduced by the 5.5.0 version of firebase-admin. The tests do not fail on version 5.4.3.

The devDependency libraries are also really out-of-date, but updating them to the latest chai, mocha and sinon does not fix the problem.

> mocha --reporter spec

  Cloud Functions
    makeUpperCase
Uppercasing undefined null
      1) should upper case input and write it to /uppercase
    addMessage
      2) should return a 303 redirect


  0 passing (312ms)
  2 failing

  1) Cloud Functions makeUpperCase should upper case input and write it to /uppercase:
     TypeError: Cannot read property 'toUpperCase' of null
      at exports.makeUppercase.functions.database.ref.onWrite.event (index.js:57:33)
      at Object.<anonymous> (node_modules/firebase-functions/lib/cloud-functions.js:59:27)
      at Generator.next (<anonymous>)
      at node_modules/firebase-functions/lib/cloud-functions.js:28:71
      at __awaiter (node_modules/firebase-functions/lib/cloud-functions.js:24:12)
      at Object.cloudFunction [as makeUppercase] (node_modules/firebase-functions/lib/cloud-functions.js:53:36)
      at Context.it (test/test.js:112:50)

  2) Cloud Functions addMessage should return a 303 redirect:
     TypeError: Attempted to wrap undefined property database as function
      at checkWrappedMethod (node_modules/sinon/lib/sinon/util/core.js:78:29)
      at Object.wrapMethod (node_modules/sinon/lib/sinon/util/core.js:129:21)
      at Object.stub (node_modules/sinon/lib/sinon/stub.js:67:26)
      at Context.it (test/test.js:130:28)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
nicolasgarniercommented, Dec 20, 2017

Ok I was able to get it to work.

First you need the latest version of sinon:

npm install --save sinon@latest

Then change the way we stub admin.database because it is a getter and not a property:

Change test.js L.131 from:

databaseStub.returns( { ref: refStub });

to:

databaseStub.get(() => (() => ({ ref: refStub })));

I’ll try to get the docs updated tomorrow.

2reactions
cinmaycommented, Dec 14, 2017

I had the same problem. In the makeUpperCase test. The DeltaSnapshot interface has changed with the new update. It now requires an extra parameter ‘instance’. To make the test pass change line 84 from data: new functions.database.DeltaSnapshot(null, null, null, 'input'), to data: new functions.database.DeltaSnapshot(null, null, null, null, 'input'),

I have not looked into why addMessage fails.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase Apple SDK Release Notes - Google
Fixed a zip distribution issue where the Promises module caused linking to fail (#10071). Limited dependency on GTMSessionFetcher version to < 2.1.0 to...
Read more >
Unable to run the unit tests after integrating Firebase SDK ...
I have solved the problem by adding FirebaseInstanceID Framework to my target(click on the framework and check if its has been added to...
Read more >
firebase_core | Flutter Package - Pub.dev
Flutter plugin for Firebase Core, enabling connecting to multiple ... FEAT: update Firebase Android SDK to 28.3.1 & Firebase iOS SDK to 8.6.0...
Read more >
ref().update() from within onComplete callback causes [Error
firebase.database().ref().update(updates); }); })(i); }. When I run this from a Node JS server (v4.4.3) with Firebase JS SDK v3.1.0 I see the following...
Read more >
Firestore pod failing after update - Hacking with Swift
I recentlly updated my pod files (pod update) which i have for over a year with my app. I am now getting this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found