I'm writing a unit test, using supertest, for middleware that requires another piece of middleware to have been run. The other middleware inserts a property onto the req, which the middleware I care about uses.
Is there a more elegant way of inserting something to the req than creating a wrapper app like this:
var wrapp = express();
wrapp.use( function (req, res, next) {
req.otherMWAdded = somedata;
next();
});
wrapp.use(testingMWA);
var req = request(wrapp).get('/someurl').end( function (err, res) {
});