Write Tests for the Service
Follow best practices and write tests for the new "cross-post-to-devto" service you created in the previous lessons.
We'll cover the following
In this lesson, following best practices, we are going to write a test for the new cross-post-to-devto
service. Some people prefer a separate test directory, while others like their test files located next to the production code itself. We will take a “keep-my-tests-close-to-the-code” approach in this course. The concepts you will learn apply regardless of where the tests are located, and you can follow your own preference.
Writing test
All paths and commands below are relative to
services/web/firebase/functions
.
Start by installing three necessary NPM packages:
npm i -D mocha chai sinon
Each of these dependencies can easily be covered in three separate courses. Please visit their websites for more details, or feel free to use your own testing libraries of choice.
Get hands-on with 1400+ tech skills courses.