title: unit testing firebase HttpsFunctions
body: <p>I am using firebase https function and am running unit tests on them. When calling the https function to be tested, the firebase documentation suggest to simply call it within my test file like this:</p>
  
  <p><code>toBeTestesFunction()</code></p>
  
  <p>This is my firebase https function:</p>
  
  <p><code>export const toBeTestedFunction = https.onRequest(async (req, resp) =&gt; {
        bla bla bla
  }</code></p>
  
  <p>Now my problem is that onRequest takes a callback which in my case is asynchronous and needs to be awaited. However onRequest return the type HttpsFunction which is of type:</p>
  
  <p><code>TriggerAnnotated &amp; ((req: Request, resp: Response) =&gt; void);</code></p>
  
  <p>Since it does not return a promise I cannot await it. This makes the content in the function which has a callback that is asynchronous untestable. In the firebase documentation they give an exmaple which seems flawed (<a href="https://firebase.google.com/docs/functions/unit-testing?authuser=0#test-background" rel="nofollow noreferrer">https://firebase.google.com/docs/functions/unit-testing?authuser=0#test-background</a>).</p>
  
  <p>Any help is much appreciated
  Thanks</p>