This middleware is not showing up when running in Supertest:
app.use((err, req, res, next) => {
// WHY DOES Supertest NOT SHOW THIS ERROR??
console.log("error: ", err.message);
res.status(422).send({ error: err.message });
});
I just spent a silly amount of time trying to find this error:
Driver.findByIdAndDelete(driverId) // Remove NOT Delete
.then(driver => {
res.status(204).send(driver)
})
...
The middleware properly showed the error as a response to the body, when using Postman, but not while running the tests.
I have 2 terminal windows open running npm run: test
and start
and nothing showed up here helpful until running Postman.
Is there a way to access this log output even when running Supertest?
package.json:
"dependencies": {
"body-parser": "^1.17.1",
"express": "^4.15.2",
"mocha": "^3.2.0",
"mongoose": "^4.8.6"
},
"devDependencies": {
"nodemon": "^1.11.0",
"supertest": "^3.0.0"
}