how to test Cloud Functions for Firebase locally on pc

前端 未结 9 1486
耶瑟儿~
耶瑟儿~ 2020-11-27 16:39

Today Firebase released its brand new product Cloud Functions for Firebase and I just created a hello world function and deploy it on my existing firebase project.

I

9条回答
  •  清酒与你
    2020-11-27 16:55

    run and debug/inspect functions locally

    prerequisites (google-cloud functions and firebase-specific):

    npm install -g @google-cloud/functions-emulator
    npm install --save firebase-functions
    npm install -g firebase-tools
    

    To run and inspect/debug: first run functions locally, then inspect each function, and finally run each specific function to debug+inspect it. Use functions start as an alternative to firebase serve and note the documentation for each tool is available (and useful).

    To run and debug the specific function myFn as-expected (eg in Nodejs via chrome://inspect and note this works using Nodejs v10 though not officially supported):

    firebase serve --only functions
    functions inspect myFn
    functions call myFn # or call from browser
    

    additional documentation:

    https://firebase.google.com/docs/functions/local-emulator https://cloud.google.com/functions/docs/emulator#debug-emulator https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki

提交回复
热议问题