Description
Operating System
macOS
Environment (if applicable)
Any Modern Browser, Chrome
Firebase SDK Version
@firebase/[email protected]
Firebase SDK Product(s)
Firestore, Storage
Project Tooling
Angular App
$ ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 19.1.7
Node: 20.18.1
Package Manager: npm 11.1.0
OS: darwin arm64
Angular: 19.1.6
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
... service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1901.7
@angular-devkit/build-angular 19.1.7
@angular-devkit/core 19.1.7
@angular-devkit/schematics 19.1.7
@angular/cli 19.1.7
@angular/fire 19.0.0
@schematics/angular 19.1.7
rxjs 7.8.1
typescript 5.7.3
zone.js 0.15.0
Detailed Problem Description
emulatorFromEnvVar
assumes that it is running in a Node.js environment with access to process.env
, however this test library is useful for browser based applications.
It would be nice if this method could check for process
to be defined before attempting to use it. It would also be nice if initializeTestEnvironment
config (TestEnvironmentConfig
) would allow you to skip configurations that you don't need. For example, I am running the emulator with --only auth,firestore,storage
. So if hub
could figure out that I have firestore
and storage
but not database
running and just configure those that would be less noise in my code.
Steps and code to reproduce issue
const testEnv = await initializeTestEnvironment({
// @firebase/rules-unit-testing assumes it is running in a node.js environment, but Angular
// is running in a browser with webpack and so `process is not defined` will be thrown here
// unless _every_ configuration is set so the code doesn't try to load one using environment
// variables.
// Also note that in order to add debugging statements to node_modules/@firebase/rules-unit-testing/dist/esm/index.esm.js
// that will actually be picked up by webpack you need to run `ng cache clean` after every
// change.
database: {
host: '125.0.0.1',
port: 9000,
},
firestore: {
host: '127.0.0.1',
port: 8080,
},
hub: {
host: '127.0.0.1',
port: 4400,
},
projectId: 'brainfry-app',
storage: {
host: '127.0.0.1',
port: 9199,
},
});
See the full app: https://github.com/rgant/brainfry/blob/47c25d00814520c4f90e7565bd9d601d2cb5c9dd/src/testing/firestore-data.ts#L28