title: Permission errors unit-testing Google Cloud Functions calling firestore db
body: <p>I'm following the guide at <a href="https://firebase.google.com/docs/functions/unit-testing" rel="nofollow noreferrer">https://firebase.google.com/docs/functions/unit-testing</a>, but I always get " FirebaseError: Missing or insufficient permissions" when I run my test. I have the correct <code>service-account.json</code> file and I'm setting up <code>firebase-functions-test</code> with it (that part goes without error).</p>
  
  <p>I've tried it with the emulator running (setting the FIRESTORE_EMULATOR_HOST var), and without it (which I assume uses live data) but I always get this error, as soon as my code under test does a db request such as:</p>
  
  <pre><code>  data = await db().collection('/machines').get()
  </code></pre>
  
  <p>So my function under test is getting called, but it just can't do anything.
  I also tried calling <code>firebase.initializeApp()</code> the same way I do in my front-end app, but that doesn't help, although without it I get the error telling me to call Firebase App.initializeApp().</p>
  
  <p><code>firebase use</code> is set to my current project.</p>
  
  <p>I also tried running my test as <code>firebase emulators:exec jest</code>, no difference.</p>
  
  <p>Any ideas?</p>