-
Notifications
You must be signed in to change notification settings - Fork 218
Description
[REQUIRED] Environment info
firebase-tools: 9.8.0
firebase --version => 9.8.0
Platform: Windows 10
[REQUIRED] Test case
Just set some functions config variables and try to access them while you run firebase emulators:exec "script"
You can try my repository
https://github.com/immunity20/firebase-emulators-exec-windows-10/tree/main
[REQUIRED] Steps to reproduce
Inside the functions folder:
firebase login
firebase use appName
firebase functions:config:get | ac .runtimeconfig.json
npm install
npm run build && firebase emulators:start --debug --only functions,firestore debig output includes the runtimeconfig.json variables
Everything works fine.
But if I try to run tests with jest
firebase emulators:exec --only firestore 'SET NODE_ENV=testing&& SET FIRESTORE_EMULATOR_HOST=localhost:8080&& npx jest --silent --verbose --detectOpenHandles'
tests fails because of undefined variables -> console.log(firebase.config()); prints an empty object {}
[REQUIRED] Expected behavior
Run jest with loaded runtimeconfig.json variables
Tests throw error "can not read key of undefined"
> firebase emulators:exec --debug --only firestore 'SET NODE_ENV=testing&& SET FIRESTORE_EMULATOR_HOST=localhost:8080&& npx jest --silent --verbose --detectOpenHandles'
[2021-03-29T20:35:08.659Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2021-03-29T20:35:08.661Z] > authorizing via signed-in user
i emulators: Starting emulators: firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: firestore"}}
[2021-03-29T20:35:08.680Z] [hub] writing locator at C:\Users\iMMuNiTy\AppData\Local\Temp\hub-app-dev-ds434.json
[2021-03-29T20:35:08.703Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[2021-03-29T20:35:08.703Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2021-03-29T20:35:08.703Z] Starting Firestore Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","C:\\Users\\iMMuNiTy\\.cache\\firebase\\emulators\\cloud-firestore-emulator-v1.11.7.jar","--host","localhost","--port",8080,"--rules","C:\\Users\\iMMuNiTy\\Documents\\GitHub\\app-network\\firebase\\firestore.rules"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"C:\\\\Users\\\\iMMuNiTy\\\\.cache\\\\firebase\\\\emulators\\\\cloud-firestore-emulator-v1.11.7.jar\",\"--host\",\"localhost\",\"--port\",8080,\"--rules\",\"C:\\\\Users\\\\iMMuNiTy\\\\Documents\\\\GitHub\\\\app-network\\\\firebase\\\\firestore.rules\"],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"functions_emulator\",\"seed_from_export\"],\"joinArgs\":false}"}}
i firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[2021-03-29T20:35:09.664Z] API endpoint: http://localhost: {"metadata":{"emulator":{"name":"firestore"},"message":"API endpoint: http://localhost:"}}
[2021-03-29T20:35:09.664Z] 8080
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:
export FIRESTORE_EMULATOR_HOST=localhost:8080
Dev App Server is now running.
{"metadata":{"emulator":{"name":"firestore"},"message":"8080\nIf you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:\r\n\n export FIRESTORE_EMULATOR_HOST=localhost:8080\n\nDev App Server is now running.\n\r\n"}}
i Running script: SET NODE_ENV=testing&& SET FIRESTORE_EMULATOR_HOST=localhost:8080&& npx jest --silent --verbose --detectOpenHandles
[2021-03-29T20:35:09.763Z] Running SET NODE_ENV=testing&& SET FIRESTORE_EMULATOR_HOST=localhost:8080&& npx jest --silent --verbose --detectOpenHandles with environment {"ALLUSERSPROFILE":"C:\\ProgramData","APPDATA":"C:\\Users\\iMMuNiTy\\AppData\\Roaming","CHROME_CRASHPAD_PIPE_NAME":"\\\\.\\pipe\\crashpad_47216_RGASUNMIHOOKKNSS","COLOR":"1","COLORTERM":"truecolor","CommonProgramFiles":"C:\\Program Files\\Common Files","CommonProgramFiles(x86)":"C:\\Program Files (x86)\\Common Files","CommonProgramW6432":"C:\\Program Files\\Common Files","COMPUTERNAME":"DESKTOP-V0T5LL4","ComSpec":"C:\\WINDOWS\\system32\\cmd.exe","DEBUG":"true","dp0":"C:\\Users\\iMMuNiTy\\Documents\\GitHub\\app-network\\firebase\\functions\\node_modules\\.bin\\","DriverData":"C:\\Windows\\System32\\Drivers\\DriverData","EDITOR":"notepad.exe","FPS_BROWSER_APP_PROFILE_STRING":"Internet Explorer","FPS_BROWSER_USER_PROFILE_STRING":"Default","GIT_ASKPASS":"c:\\Program Files\\Microsoft VS Code\\resources\\app\\extensions\\git\\dist\\askpass.sh","GPU_FORCE_64BIT_PTR":"0","GPU_MAX_ALLOC_PERCENT":"100","GPU_MAX_HEAP_SIZE":"100","GPU_SINGLE_ALLOC_PERCENT":"100","GPU_USE_SYNC_OBJECTS":"1","HOME":"C:\\Users\\iMMuNiTy","HOMEDRIVE":"C:","HOMEPATH":"\\Users\\iMMuNiTy","INIT_CWD":"C:\\Users\\iMMuNiTy\\Documents\\GitHub\\app-network\\firebase\\functions","IS_FIREBASE_CLI":"true","LANG":"en_US.UTF-8","LOCALAPPDATA":"C:\\Users\\iMMuNiTy\\AppData\\Local","LOGONSERVER":"\\\\DESKTOP-V0T5LL4","NODE":"C:\\Program Files\\nodejs\\node.exe","NODE_EXE":"C:\\Program Files\\nodejs\\\\node.exe","NPM_CLI_JS":"C:\\Users\\iMMuNiTy\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js","npm_command":"run-script","npm_config_cache":"C:\\Users\\iMMuNiTy\\AppData\\Local\\npm-cache","npm_config_globalconfig":"C:\\Users\\iMMuNiTy\\AppData\\Roaming\\npm\\etc\\npmrc","npm_config_https://npm.fontawesome.com/ae809d71_943c_4e1a_96f8_e56c6d89a405":"","npm_config_init.module":"C:\\Users\\iMMuNiTy\\.npm-init.js","npm_config_init_module":"C:\\Users\\iMMuNiTy\\.npm-init.js","npm_config_metrics_registry":"https://registry.npmjs.org/","npm_config_msvs_version":"2017","npm_config_node_gyp":"C:\\Users\\iMMuNiTy\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js","npm_config_prefix":"C:\\Users\\iMMuNiTy\\AppData\\Roaming\\npm","npm_config_python":"/path/to/executable/python2.7","npm_config_userconfig":"C:\\Users\\iMMuNiTy\\.npmrc","npm_config_user_agent":"npm/7.4.0 node/v14.15.3 win32 x64","npm_execpath":"C:\\Users\\iMMuNiTy\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js","npm_lifecycle_event":"test:windows","npm_lifecycle_script":"firebase emulators:exec --debug --only firestore 'SET NODE_ENV=testing&& SET FIRESTORE_EMULATOR_HOST=localhost:8080&& npx jest --silent --verbose --detectOpenHandles'","npm_node_execpath":"C:\\Program Files\\nodejs\\node.exe","npm_package_engines_node":"14","npm_package_json":"C:\\Users\\iMMuNiTy\\Documents\\GitHub\\app-network\\firebase\\functions\\package.json","npm_package_name":"functions","NPM_PREFIX_NPM_CLI_JS":"C:\\Users\\iMMuNiTy\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js","NUMBER_OF_PROCESSORS":"12","OneDrive":"C:\\Users\\iMMuNiTy\\OneDrive","OneDriveConsumer":"C:\\Users\\iMMuNiTy\\OneDrive","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","OS":"Windows_NT","Path":"C:\\Users\\iMMuNiTy\\Documents\\GitHub\\app-network\\firebase\\functions\\node_modules\\.bin;C:\\Users\\iMMuNiTy\\Documents\\GitHub\\app-network\\firebase\\node_modules\\.bin;C:\\Users\\iMMuNiTy\\Documents\\GitHub\\app-network\\node_modules\\.bin;C:\\Users\\iMMuNiTy\\Documents\\GitHub\\node_modules\\.bin;C:\\Users\\iMMuNiTy\\Documents\\node_modules\\.bin;C:\\Users\\iMMuNiTy\\node_modules\\.bin;C:\\Users\\node_modules\\.bin;C:\\node_modules\\.bin;C:\\Users\\iMMuNiTy\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\@npmcli\\run-script\\lib\\node-gyp-bin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;c:\\program files (x86)\\intel\\intel(r) management engine components\\icls\\;c:\\program files\\intel\\intel(r) management engine components\\icls\\;c:\\windows\\system32;c:\\windows;c:\\windows\\system32\\wbem;c:\\windows\\system32\\windowspowershell\\v1.0\\;c:\\program files (x86)\\intel\\intel(r) management engine components\\dal;c:\\program files\\intel\\intel(r) management engine components\\dal;c:\\program files (x86)\\intel\\intel(r) management engine components\\ipt;c:\\program files\\intel\\intel(r) management engine components\\ipt;c:\\program files\\git\\cmd;c:\\program files\\putty\\;c:\\windows\\system32\\openssh\\;c:\\program files\\nvidia corporation\\nvidia
nvdlisr;c:\\program files (x86)\\yarn\\bin\\;c:\\program files\\microsoft vs code\\bin;c:\\program files\\samsung\\allshare framework dms\\1.3.23\\;c:\\program files\\samsung\\allshare framework dms\\1.3.23\\64bit\\;c:\\users\\immunity\\appdata\\local\\programs\\python\\python37\\scripts;;c:\\program files (x86)\\gpg4win\\..\\gnupg\\bin;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Program Files\\nodejs\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Users\\iMMuNiTy\\AppData\\Local\\Programs\\Python\\Python37\\Scripts\\;C:\\Users\\iMMuNiTy\\AppData\\Local\\Programs\\Python\\Python37\\;C:\\Users\\iMMuNiTy\\.windows-build-tools\\python27\\;C:\\Users\\iMMuNiTy\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Users\\iMMuNiTy\\AppData\\Local\\GitHubDesktop\\bin;;C:\\Program Files\\heroku\\bin;C:\\Users\\iMMuNiTy\\AppData\\Local\\Yarn\\bin;C:\\Users\\iMMuNiTy\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\iMMuNiTy\\AppData\\Roaming\\npm","PATHEXT":".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JSE;.WSF;.WSH;.MSC;.CPL","PREFIX":"C:\\Users\\iMMuNiTy\\AppData\\Roaming\\npm","PROCESSOR_ARCHITECTURE":"AMD64","PROCESSOR_IDENTIFIER":"Intel64 Family 6 Model 158 Stepping 10, GenuineIntel","PROCESSOR_LEVEL":"6","PROCESSOR_REVISION":"9e0a","ProgramData":"C:\\ProgramData","ProgramFiles":"C:\\Program Files","ProgramFiles(x86)":"C:\\Program Files (x86)","ProgramW6432":"C:\\Program Files","PROMPT":"$P$G","PSModulePath":"C:\\Users\\iMMuNiTy\\Documents\\WindowsPowerShell\\Modules;C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules;C:\\Program Files\\Intel\\Wired Networking\\","PUBLIC":"C:\\Users\\Public","SESSIONNAME":"Console","SystemDrive":"C:","SystemRoot":"C:\\WINDOWS","TEMP":"C:\\Users\\iMMuNiTy\\AppData\\Local\\Temp","TERM_PROGRAM":"vscode","TERM_PROGRAM_VERSION":"1.54.3","TMP":"C:\\Users\\iMMuNiTy\\AppData\\Local\\Temp","USERDOMAIN":"DESKTOP-V0T5LL4","USERDOMAIN_ROAMINGPROFILE":"DESKTOP-V0T5LL4","USERNAME":"iMMuNiTy","USERPROFILE":"C:\\Users\\iMMuNiTy","VSCODE_GIT_ASKPASS_MAIN":"c:\\Program Files\\Microsoft VS Code\\resources\\app\\extensions\\git\\dist\\askpass-main.js","VSCODE_GIT_ASKPASS_NODE":"C:\\Program Files\\Microsoft VS Code\\Code.exe","VSCODE_GIT_IPC_HANDLE":"\\\\.\\pipe\\vscode-git-c5c9e8fbe0-sock","windir":"C:\\WINDOWS","_prog":"node","GCLOUD_PROJECT":"app-dev-ds434","FIRESTORE_EMULATOR_HOST":"localhost:8080","FIREBASE_FIRESTORE_EMULATOR_ADDRESS":"localhost:8080","FIREBASE_EMULATOR_HUB":"localhost:4400"}