How to Test Firebase Cloud Functions using Jest

Published: Wednesday, Jun 21, 2017
Cover

The Firebase Cloud Functions Unit Testing documentation and quickstart samples only show how to write unit tests for Firebase Cloud Functions using Mocha with Sinon and Chai. And the quickstarts don’t even do a thorough job of demonstrating how to write unit tests.

I prefer to use Jest for unit tests. For others who feel the same, and for those who want to see more examples of how to unit test Firebase Cloud Functions, I wanted to help. I’ve created a Github repo that demonstrates how to replace the existing Mocha tests with Jest tests and how to write new Jest tests for the quickstarts that didn’t have tests.

Check it out: https://github.com/jedfonner/firebase-functions-jest and let me know what you think.