I'm trying to test Firestore's security rules on my GitLab CI pipeline. I need to run Firebase's emulator to accomplish that.
However, the Firebase emulator basically starts serving a "fake backend". So, how can I run that job in parallel to other jobs?
For example:
stages:
- emulator
- test
emulator:
- stage: emulator
script:
- firebase serve --only firestore
test:
- stage: test
script:
- yarn test
The test
stage is never reached as GitLab is serving the emulator
stage. Therefore, it never finishes.
You should not use 2 stages. Keep in mind, each stage is a completely independent "computer" started somewhere. So one stage can per default not interact with another.
The script
part of a stage is practically a shell script. So if you want to try if everything works, create a shell script and execute it.
Here is what I did. Keep in mind it's I didn't test it with your particular setup
stages:
- test
test:
- stage: test
script:
- yarn compile
- yarn firebase setup:emulators:firestore
- yarn firebase emulators:exec -P dev1 --only firestore "yarn test --exit"
To use the emulator with tests on a CI
system it's best you add a "start" script. In this case I'm adding the test yarn test --exit
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