firebase/quickstart-nodejs

database-emulator/javascript-quickstart's default test.js npm test fail with error

FeynmanDNA opened this issue · 5 comments

I git cloned the repo, and successfully did npm install. However, when I try to run npm test (without changing any default code), the test fails with "before" and "after" not defined error:

> database-emulator-javascript-quickstart@1.0.1 pretest /home/quickstart-nodejs/database-emulator/javascript-quickstart
> eslint test/*.js


/home/quickstart-nodejs/database-emulator/javascript-quickstart/test/test.js
  40:1  error  'before' is not defined  no-undef
  53:1  error  'after' is not defined   no-undef

Is this related to mocha? (i suspect it is the eslint linting issues)

I cannot replicate this on my workstation.

Can you give me a bit more info about your setup?

  • What git commit are you running against? (git rev-parse HEAD)
  • Double-check that there are no local changes to the code. (git status)
  • What OS are you using?
  • What version of Node are you running?

@ryanpbrewster Hi, I figured out how I got those errors.

So if I do not start the local serve firebase serve --only database, I will get these errors when I run npm test:

$ npm test

> database-emulator-javascript-quickstart@1.0.1 pretest quickstart-nodejs/database-emulator/javascript-quickstart
> eslint test/*.js


> database-emulator-javascript-quickstart@1.0.1 test quickstart-nodejs/database-emulator/javascript-quickstart
> mocha



(node:7545) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
  1) "before all" hook

  0 passing (25ms)
  1 failing

  1) "before all" hook:
     Error: connect ECONNREFUSED 127.0.0.1:9000
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)



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

If I start and keep the firebase serve --only database running, the npm test is able to proceed fine.

Thanks for the reply. Appreciate your help!

Glad to hear it, and thank you for following up with more information that my be useful to other developers!