You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
given the following files
.runtimeconfig.json //my env keys stored here
foo.js
test/test.js
test/myProjServiceKey.json //from gcp > Iam > service account, app engine
in my code:
//foo.jsconstfunctions=require('firebase-functions');constconfig=functions.config();//ERRORS HERE my line 23.console.log(config.somefoo.key);//prints out a key so i know its setup
//test/test.jsconstconfig=require('../.runtimeconfig.json');constprojectConfig={projectId: '<my project>'};//inserted my project idconsttest=require('firebase-functions-test')(projectConfig,'./myProjServiceKey.json');test.mockConfig({ config });//also tried manually entering in values.console.log(config.somefoo.key);//prints out a key so i know its setup//...later in the codedescribe('not working Test3 ',()=>{before(()=>{constmyFoo=require('../foo');//ERRORS HERE my line 106});after(()=>{test.cleanup();});describe('...',function(){it('...',()=>{//const wrap = test.wrap(myFoo.run); //run() inside class Foo.});});});
running npm test, I get an error
> Error: Firebase config variables are not available. Please use the latest version of the Firebase CLI to deploy this function.
> at init (node_modules/firebase-functions/lib/config.js:55:15)
> at Object.config (node_modules/firebase-functions/lib/config.js:29:9)
> at Object.<anonymous> (foo.js:23:26)
> at require (internal/module.js:11:18)
> at Context.before (test/test.js:106:27)
I made sure, I mocked functions.config() BEFORE requiring foo.js
anything else im missing?
The text was updated successfully, but these errors were encountered:
I just ran into this issue as well. Running firebase-functions-test@0.2.1. My config is always {}; mockConfig is called before any other requires. Any ideas how to fix this?
I got mine to work by trying to set the config values manually and seeing this error: Error: Cannot set to reserved namespace firebase. I tried setting the api key to firebase.apikey variable in my mock config which apparently caused this issue. When I instead mock project.apikey it works just fine. I wish the error message was more verbose; maybe I just missed it 🤷
following your "online mode" example.
given the following files
.runtimeconfig.json //my env keys stored here
foo.js
test/test.js
test/myProjServiceKey.json //from gcp > Iam > service account, app engine
in my code:
running
npm test
, I get an errorI made sure, I mocked functions.config() BEFORE requiring foo.js
anything else im missing?
The text was updated successfully, but these errors were encountered: