I want to unit test my express controllers independently. But they interact with the mongoose models. So the question is how can I test them? For example -
const Model = require('./../models/mymodels');
const controller = (req, res) => {
const body = req.body;
const foo = new Model(body);
foo.save().then(foo => res.send(foo)).catch(err => res.send(error));
};
So I want to test the funtion controller independently.
Aucun commentaire:
Enregistrer un commentaire