I want to make a gulp task to run all my tests with mocha with one single command. (My test need to connection to DB with mongoose)
Then I got this error:
{ [Error: Trying to open unclosed connection.] state: 1 }
After some research, I found this post: Mongoose Trying to open unclosed connection
It said I should use createConnection()
instead of 'connect()`.
Here is the question now:
How could I use before
and after
for the test, and how could I call done
after db connected before go through each test cases?