Hello I just try to do some functional test with mocha + chai on nodeJS api and everytime I try something even if it's not what expected from test, the test seems to pass.
Here is my test code :
const server = require("../server");
const chai = require("chai");
const chaiHttp = require("chai-http");
chai.use(chaiHttp);
const expect = require("chai").expect;
const requester = chai.request(server);
describe("test user", function(){
describe("get all", function(){
it("should return all users and 400", function(){
requester.get("/api/users")
.then(function(res){
console.log(res.status);
expect(res).to.have.status(400);
})
.catch(function(err){
throw(err);
})
})
})
})
and this is what I get :
> backend@1.0.0 test
> mocha "tests/users.test.js"
App listening at http://:::4000
test user
get all
✔ should return all users and 400
1 passing (13ms)
Successfully connected to MongoDB.
200
since I wait 400 and get 200 it should fail but it isn't.