i have function "login" which is ended by this execution:
res.status(202).json({ token, userId: user._id.toString() });
In test i mocking res object like this:
const res = {
status: jest.fn(),
json: jest.fn(),
};
but i get TypeError: Cannot read property 'json' of undefined.
When i delete status() execution in "login" function & leave only json(), error is not thrown.
I'm using Jest for testing. What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire