When using express, the middleware "body-parser" can be utilized to automatically parse the incoming body.
However, in the absence of an express router to apply the middleware to, is there a way to implement it for all requests in my chai test file? This would ensure adherence to the DRY (Don't Repeat Yourself) principle.
Currently, I find myself repeating this code in every test:
it('login', done => {
request.post('http://localhost:3000', (err, res, body) => {
JSON.parse(body) // <-- Parsing the body each time
done();
})
});