dimanche 15 novembre 2020

How to test Nodejs controllers

How will I test this controller in Nodejs.

    try {
        const first = await First({});
        const second = await Second({});
        return res.json({
            ok: true,
            totalCount: {
                 first,
                 second
            },
        });
    } catch (error) {
        return res.status(500).json({ ok: false, error : error.message });
    }
};

I am trying Sinon. But not able to get any return value in the testing log for the controller. Please help me with the testing of the controller.

Aucun commentaire:

Enregistrer un commentaire