I run the following test and its not stopping in the actions of the express router The URL is exactly the url which I put in postman and works ,any idea?
describe('test', function () {
it('Should Run///',
function (done) {
supertest(app)
.post('http://localhost:3002//save/test1/test2/test3')
.expect(200)
.end(function (err, res) {
res.status.should.equal(200);
done();
});
});
in the following code its not stopping in the post (console.log...)what am I missing here?
module.exports = function (app, express) {
var appRouter = express.Router();
app.use(appRouter);
//Route Application Requests
appRouter.route('*')
.post(function (req, res) {
console.log("test");
})
You're not sending a response in your route handler:
appRouter.route('*')
.post(function (req, res) {
console.log("test");
return res.sendStatus(200); // <-- actually send back a response!
});
Also, it seems from your code that you are passing an Express app and not a server to Supertest, in which case you probably need to use this:
.post('/save/test1/test2/test3')
(instead of a full url)