I'm not using separate databases for production and development. First I tried to test my modules which connects me to mongodb. This works fine. I'm using chai and mocha to do this.
Structure of my server files: So when the user hits the route(i.e any url) , route callback calls modules to perform the operation on the db. This is the way server files are organised.
User can hit the route and get/post the data on it.I wrote test cases to test the modules which deals with the mongodb this is great and works.
Now I'm tring to test my routes by the below code but when I'm using it my previous assertion breaks and if I comment out the below code all works great.
var serverAddress='http://localhost:8080';
var chaiHttp = require('chai-http');
chai.use(chaiHttp);
describe('login/user', function() {
it('should login user to the server', function(){
chai.request(serverAddress)
.post('/login/user')
.send({ email: "sandeep@admin.com", password: "admin" })
.then(function (res) {
expect(res).to.have.status(200);
})
.catch(function (err) {
throw err;
})
});
it('should not login user to the server');
});
Error looks like this:
Unhandled rejection AssertionError: expected 'AssertionError' to equal '*****'
Any kind of help will be appreciated.
Aucun commentaire:
Enregistrer un commentaire