I'm lost, I have been searching for good resources but I can't find any. How to do unit testing for a back-end NodeJS, ExpressJS, Firestore, RESTful app? What tools to use? How to mock data? I don't want to have a test database for testing, I want to mock data. Can any one help me?
Example of an endpoint:
router.post("/color", async (request, response) => {
if(Object.keys(request.body).length === 0) return response.status(406).send("Ups... There was missing data.");
try {
await db.collection('Colors').add({
realColor: request.body.realColor,
colorMap: request.body.colorMap
});
response.status(201).send("Success! A color was creted!");
}
catch (error) {
console.log(error);
response.status(400).send("Ups... A color was NOT creted!");
}
});
Top comments (4)
Did you find your way through it? I'm curious about it too.
Sadly, no. We just mock data with sinnon, and check response statuses, but i dont think its correct unit tests
Maybe use something like Firebase Emulator or Firebase Mock?
did you find any way guys ??