Hi I am new to testing with Mocha let alone async testing. I keep getting the following error when running this test. I have spend a lot of time researching the resolution on the web but no luck.
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
it('Should fail to create new user due to missing email', (done) => {
const user_empty_email = {
name: "First Name",
email: "",
password: "password",
isAdmin: false
}
chai.request(app).post('/v1/users')
.send(user_empty_email)
.then((res) => {
expect(res).to.have.status(400);
done();
}).catch(done)
})
Below is an example response I am getting fir the /v1/users
{
"user": {
"_id": "5de4293d3501dc21d2c5293c",
"name": "Test Person",
"email": "testemail@gmail.com",
"password": "$2a$08$8us1C.thHWsvFw3IRX6o.usskMasZVAyrmccTNBjxpNQ8wrhlBt6q",
"isAdmin": false,
"tokens": [
{
"_id": "5de4293d3501dc21d2c5293d",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZGU0MjkzZDM1MDFkYzIxZDJjNTI5M2MiLCJpYXQiOjE1NzUyMzM4NTN9.mi4YyYcHCvdYrl7OuI5eDwJ8xQyKWDcqgKsXRYtn0kw"
}
],
"__v": 1
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZGU0MjkzZDM1MDFkYzIxZDJjNTI5M2MiLCJpYXQiOjE1NzUyMzM4NTN9.mi4YyYcHCvdYrl7OuI5eDwJ8xQyKWDcqgKsXRYtn0kw"
}