firebase functions local emulator?

1,399 views
Skip to first unread message

Eli Horne

unread,
Mar 11, 2017, 9:19:15 PM3/11/17
to Firebase Google Group
This may be a stupid question, but do firebase functions work in the local environment? 

I notice that google cloud functions provide a local emulator (in alpha) for this specific purpose, but as far as I can tell, firebase functions don't work until you deploy them to the cloud and get your "us-central1-[app name]" URL.  Hitting localhost:500/[function name] returns a 404.

If I'm wrong, please correct me. If I'm right, could you advise on recommended development techniques?

Quentin Veyret

unread,
Mar 12, 2017, 5:51:24 PM3/12/17
to Firebase Google Group
Hi Eli,

You might want to watch this talk from Google Cloud Next'17: https://youtu.be/7e0RGIul8Kk?t=30m36s

What you should do is use ngrok in order to expose your localhost to the cloud so you can set up Firebase events to call you ngork URL that is mapped to your localhost.

Hope this helps.

Best,
Quentin

Doug Stevenson

unread,
Mar 12, 2017, 5:52:38 PM3/12/17
to Firebase Google Group
Eli,

Unfortunately, this does not exist today.  A local environment for building and testing Cloud Functions is a high priority for the engineering team.

In the meantime, you could abstract away the core functionality of your function and invoke it directly with the node command line, passing in all necessary data that it needs to operate.  For example, with an HTTPS function, figure out what you need from the request object, make that the input to another function, then invoke that with dummy data that you create.  The response could be handled similarly.

You could also run Express locally and wire it up to invoke your function (since that's what implements the request and response objects).

Doug

Eli Horne

unread,
Mar 13, 2017, 5:33:48 PM3/13/17
to Firebase Google Group
Thanks for the replies. I'll keep an eye out for local development ... developments :)

My Firebase Functions were previously in an express app, but I made some modifications (switching to exports, service file authentication etc) and I'm not expert enough to seamlessly switch between the two.

Jacob Wenger

unread,
Mar 13, 2017, 6:10:29 PM3/13/17
to fireba...@googlegroups.com
Also check out our docs on Unit Testing of Cloud Functions. That has some good information which you might find useful.

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/41113b91-56e3-4b84-b76b-c1ac153cf110%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages