I am writing a unit test to test my postgres schema. I am using node-pg, mocha, sinon, and chai.
This works - the test passes with no issues:
describe('When adding a user', ()=> {
it('should reject since email is used somewhere else', (done)=> {
pool.query(`INSERT INTO users(email, id, token)
VALUES($1, $2, $3)`, ['foo@email.com', '12346', 'fooToken'])
.then((result)=> {
console.log('nothing in here runs, you will not see this');
done()
})
.catch((result) => {
result.constraint.should.have.string('email_already_exists');
done();
})
})
});
But to make sure I am not getting a false positive, I change the assert to result.constraint.should.not.have.string('email_already_exists');
to purposely make the test fail.
Instead of the test failing, I get Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
.
What am I getting this?