firebase-tools
firebase-tools copied to clipboard
`process.env.FUNCTIONS_EMULATOR` is not defined when using `firebase emulators:exec`
[REQUIRED] Environment info
firebase-tools: 11.6.0
Platform: Windows, Ubuntu, Mac
[REQUIRED] Test case
Have a Callable Cloud Function and call
functions.logger.info(`Functions Emulator: ${process.env.FUNCTIONS_EMULATOR}`)
within this cloud function.
[REQUIRED] Steps to reproduce
- Run the Cloud Functions emulator using
firebase emulators:start=> The log from the test case will outputFunctions Emulator: true. - Have a test case that calls this Callable Cloud Function via
firebase-functions-testfft(..). Run the test in emulator usingfirebase emulators:exec \"npm test\"=> The log from the test case will outputFunctions Emulator: undefined.
[REQUIRED] Expected behavior
process.env.FUNCTIONS_EMULATOR is also "true" if tests testing the functions are executed using firebase emulators:exec.
This is important as that's the only way we can detect whether we are running in the emulator and allows to add some exceptions for tests runs. Currently with this behavior, executions differ between "running" the emulators (via firebase emulators:start) and executing tests directly using firebase emulators:exec ....
[REQUIRED] Actual behavior
See above, when running function tests using firebase emulators:exec, process.env.FUNCTIONS_EMULATOR is not defined.