title: Cloudbuild start firebase emulator then npm test
body: <p>I have a setup that works locally. I can start the emulators, load data in firestore and then run npm test.</p>
  <p>I am not sure how to do this on cloudbuild. Here's what I have so far:</p>
  <pre><code>steps:
  - name: 'gcr.io/cloud-builders/gcloud'
    id: MOVE-DOTENV-APP-YAML
    entrypoint: bash
    args:
      - '-e'
      - '-c'
      - |
        cp functions/util/config_dev.js functions/util/config.js
        cp functions/.env_dev functions/.env
  - name: node
    dir: 'functions'
    entrypoint: npm
    args: ['install']
  - name: 'gcr.io/xxxx/firebase'
    args: ['emulators:start', '--only', 'functions,firestore', '&amp;']
  - name: node
    dir: 'functions'
    entrypoint: npm
    args: ['test']
  </code></pre>
  <p>What I want to add:</p>
  <pre><code>firebase emulators:start --only functions,firestore &amp;
  echo &quot;Waiting for emulator to load...&quot;
  while [ $(curl http://localhost:5001/xxx/us-central1/api --silent | grep &quot;Unauthorized&quot; | wc -l) -eq 0 ]; do sleep 2; done
  node import-db.js
  </code></pre>
  <p>Any ideas on how this can be achieved? I also tried building a firebase image (<a href="https://cloud.google.com/build/docs/deploying-builds/deploy-firebase" rel="nofollow noreferrer">https://cloud.google.com/build/docs/deploying-builds/deploy-firebase</a>), but it fails in the cloudbuild.yaml.</p>
  <p>The test fails at the emulator start with the following output (    emulators:start --only functions,firestore &amp; ) (but no error that can tell me what is happening)</p>
  <pre><code>Pulling image: gcr.io/xxxx/firebase
  Using default tag: latest
  latest: Pulling from xxxx/firebase
  8f04e8168e38: Already exists
  82e5f66f5d0e: Already exists
  c1c8f1c77d66: Already exists
  5095cab27771: Already exists
  ea7fe362a971: Already exists
  9000ed6ad541: Already exists
  79733a3c6015: Already exists
  10da8f37aebc: Already exists
  4641fca333ab: Already exists
  f8eea1f9fdb1: Pulling fs layer
  38ab87a43f87: Pulling fs layer
  38ab87a43f87: Verifying Checksum
  38ab87a43f87: Download complete
  f8eea1f9fdb1: Verifying Checksum
  f8eea1f9fdb1: Download complete
  f8eea1f9fdb1: Pull complete
  38ab87a43f87: Pull complete
  Digest: sha256:c73a50f73c2e19952f1d64228de99ad6c26748f6242393c420b1bfee274e2832
  Status: Downloaded newer image for gcr.io/xxxx/firebase:latest
  gcr.io/xxxx/firebase:latest
  </code></pre>