I'm using Mocha and Chai + ChaiHttp for testing my API. The problem I have is that I don't see any error messages when a expect
statement is failing.
Here is my code:
it('POST /signup : should create a new user', async () => {
const user = {
name: 'Felix',
email: 'felix@gmail.com',
password: 'test',
};
const res = await chai.request(app).post('/signup').send(user);
expect(res).to.be.json;
expect(res).to.have.status(200);
expect(res.body).to.be.an('object');
expect(res.body.success).to.equal(true);
expect(res.body.user).to.have.property('falseAttribute'); // <- test passes with "name"
expect(res.body.user).to.have.property('token');
});
When it fails because the returned use is expected to have the falseAttribute
, it simply shows me the 'it' text highlighted in red:
Authentication tests
1) POST /signup : should create a new user`)
In my package.json scripts I put "test": "NODE_ENV=test ./node_modules/.bin/mocha test"
I've already searched the internet for similar problems but I haven't found anything yet. Thank you for your help!