In one file I have ..
const express = require('express');
const app = express();
app.use(// various middleware);
app.use(routes)
module.exports = app;
In my routes.js file I have some basic routes set up which I mount on app (above file).
My question is I want to test the routes, but with all the various middleware attached. I'm using Mocha / Chai for testing.
I'm importing app from the first file.
const res = await chai
.request(app)
.get('/')
.set('cookie', `some_cookie=${cookie_value}`);
Is this the correct way? It doesn't seem to work. If I import the routes file, I'm assuming that is testing just the routes with no middlware.
Aucun commentaire:
Enregistrer un commentaire