functions-samples icon indicating copy to clipboard operation
functions-samples copied to clipboard

quickstart uppcase test failing

Open jpokrzyk opened this issue 9 years ago • 8 comments

➜ functions git:(master) ✗ npm test

uppercase-quickstart-functions@ test /Users/jon/github/examples/functions-samples/quickstarts/uppercase/functions mocha --reporter spec

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

1 passing (152ms) 1 failing

  1. Cloud Functions makeUpperCase should upper case input and write it to /uppercase: TypeError: Cannot read property 'database' of null at DeltaSnapshot.get [as ref] (node_modules/firebase-functions/lib/providers/database.js:136:37) at assignValue (node_modules/lodash/lodash.js:2493:28) at node_modules/lodash/lodash.js:2702:9 at arrayEach (node_modules/lodash/lodash.js:537:11) at baseClone (node_modules/lodash/lodash.js:2696:7) at node_modules/lodash/lodash.js:2702:34 at arrayEach (node_modules/lodash/lodash.js:537:11) at baseClone (node_modules/lodash/lodash.js:2696:7) at Function.cloneDeep (node_modules/lodash/lodash.js:11102:14) at node_modules/firebase-functions/lib/cloud-functions.js:32:32

npm ERR! Test failed. See above for more details.

jpokrzyk avatar Mar 10 '17 17:03 jpokrzyk

Having the same problem.

artuan avatar Mar 10 '17 17:03 artuan

@laurenzlong any idea?

nicolasgarnier avatar Mar 10 '17 18:03 nicolasgarnier

It seems like event.data.ref is not getting stubbed properly. (Line 100 in test/test.js). It is possible that you two have a different version of sinon installed. Could you please run "npm install" inside functions-samples/quickstarts/uppercase/functions and then run the test again, and let me know if it still fails?

laurenzlong avatar Mar 10 '17 19:03 laurenzlong

I was able to get the test to pass by doing

Object.defineProperty(fakeEvent, 'ref', { get: refStub })

aputinski avatar Mar 11 '17 00:03 aputinski

@laurenzlong Yea tried wiping the node modules and fresh npm install and same results (had tried yarn originally). Surprised it's working for you.

jpokrzyk avatar Mar 11 '17 19:03 jpokrzyk

Yeap, I am having the same issue as well! Using Sinon 1.17.7

lesterchan avatar Mar 13 '17 09:03 lesterchan

Hmmm super strange.... Thanks for the suggestion @aputinski , I'll use Object.defineProperty instead.

laurenzlong avatar Mar 13 '17 18:03 laurenzlong

Closed via #35

nicolasgarnier avatar Mar 13 '17 20:03 nicolasgarnier