Tests for Cloud functions are written using Mocha/Chai. They live within the functions/test folder.

Running Locally

Unit tests are run through mocha when calling:

yarn functions:test

Note: Coverage is genearted when running:

yarn functions:test:cov

Writing

How you write your tests for cloud functions depends on the scope you would like to cover in your test. the vanilla js testing section

Logic

As mentioned in the vanilla js testing section, we can tests simple logic directly with mocha/chai.

Full Cloud Function

Testing is slightly different between HTTP functions and other function types

Everything in tests can be mocked including Database updates and external API calls

Other Resources