Member-only story

Offline Firebase Cloud Functions Unit Testing in TypeScript

Say goodbye to surprises in production

Jackson Zhou
2 min readNov 8, 2019

Firebase Cloud Functions is a microservices solution

Firebase is an all-in-one app solution and Firebase Cloud Functions is responsible for microservices. It saves developers time by abstracting the connection from microservices to authentication, database, and storage.

TypeScript + Firebase Cloud Functions Unit Tests = No Surprises in Production

TypeScript is a typed superset of Javascript

TypeScript is Javascript but statically typed. Since Javascript is dynamically typed and it’s hard to cover all invalid types in tests, many unexpected errors can happen in production. To make production more robust, TypeScript is preferred over Javascript.

Step 1: initialize mocha/chai testing infrastructure

As suggested by Firebase official documentation, we will write tests with mocha and chai, so let’s install mocha and chai together with their types (so that TypeScript won’t yell about type errors).

--

--

Responses (1)