Timeout error for integration tests is the number 1 issue I face with Mocha test runner and Sequelize ORM library.
How do I solve it?
I can try structuring my codes so that there is less statement to cover, thereby less process to run and less memory required. But as in most integration tests, we want to cover scenarios closest to real life. That is, instead of testing solely a function, we prefer covering a complete feature. An example is, creating a login for a user and sending him or her an email of confirmation.
These types of tests usually take plenty of resources as we need to create dummy objects, manipulate them and delete them from the test database. We certainly don't want to use real APIs as they may be costly such as sending real mails to a mailing service that charges per mail.
As a result, with all these processes, most testing procedures often results in timeouts.
The best way and easiest way is to use timeouts.
In the upper most describe block, I add this.timeount(6000) or more, depending on the number of operation. This solves the problem, unless too much database access requests are required.
If you want to improve your NodeJS development skills in a few hours, I highly recommend this course: