I want to start firebase emulators before Jest tests.
Execute this, but programatically:
E:\my-projct>firebase emulators:start --only firestore
i emulators: Starting emulators: firestore
i firestore: Serving ALL traffic (including WebChannel) on http://localhost:8080
! firestore: Support for WebChannel on a separate port (8081) is DEPRECATED and will go away soon. Please use port above instead.
i firestore: Emulator logging to firestore-debug.log
+ firestore: Emulator started at http://localhost:8080
i firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
+ All emulators started, it is now safe to connect.
Therefore, I need to:
Execute the command
Wait for the "All emulators started" string to appear.
How do I read the output?
I have tried the following, all it prints is a newline.
const cp = require('child_process');
const child = cp.exec('firebase emulators:start --only firestore');
child.stdout.addListener('data', data => console.log(data.toString()));
This is exactly why we have made the firebase emulators:exec command.
So let's say you use "npm run test" to run your Jest scripts, you would use:
firebase emulators:exec "npm run test"
This will:
npm run test in this case)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With