Cloud Function Test
Test your functions before deploying to cloud. Write code locally, then test it.
Note that before deploying function to Google Cloud you have to first enable billing for your project, but using Cloud Functions is free up to a free tier quota - Google Cloud Functions Pricing
Install tester using npm
npm install cloud-function-test
- Import TestFunction class
var test = TestFunction;
- Initialize server
- Create your own function that you want to test locally.
It has to have
resparameters which will be passed to your function from the Google's server. They stand for Request and Response objects of Express framework.
Run your script. Function will be available to you on
http://localhost:portNumberyou set it to be.
Close the server
Example test case with mocha, chai an supertest
// recaptcha testconst request = ;const chai = ;const assert = chaiassert;var test = TestFunction;var reCAPTCHA = ; // function to test;