I am writing my integration tests with supertest and chai.I am assuming each request made via superagent will be equal to ones I make via postman, so I naturally expect requests to pass through express validation, but it is not happening.Here is my test case : it("#PUT Missing Name", function (done) { request(app) .put("/player/profile") .send(testData.player.putMissingName) .expect(400) .end(function (err, res) { if (err) return done(err); done(); }); }); Express validation code:req .checkBody('name') .notEmpty() .withMessage(strings.FIELD.REQUIRED) .custom(_.isString) .withMessage(strings.FIELD.INVALID); Validations work when request is sent from postman, however won't work when sent from test.I am expecting a 400 code and field required message but I get 200.What am I doing wrong?
Submitted April 02, 2018 at 08:20AM by oftencoffee
No comments:
Post a Comment