Hello, I'm also have this problem. I'm not sure if its really that its running everything in parallel, could just be that it executes the next file before the "root after" hook runs/finishes (which in my case will make the next test break). Added some prints to see what was going on with my little project, each file is being executed as follows:
carts - before hook called
carts - database cleaned
products - before hook called
carts - after hook called
products - after hook called
Then it blows up. I tried it a few times and it does the same thing over and over. What is likely happening here is that the server isn't closed (ie, there's still a connection with the database, which would make DROP DATABASE return an error afaik) when I try to rebuild the database. Thing is, I've placed the logic to close the server in the "root after" hook, which for some odd reason is being run after the "root before" hook for the next file.
I've been learning node and I made a simple project. Simply run mocha test/integration or npm run integraton to see the error. I kept the prints in.
https://github.com/AGhost-7/node-shop
I imagine that the only other way around this would be to use the programmatic API, but there should be another way to do this I think since my impression is that what I'm trying to do is (maybe) pretty common.
Any suggestions? Is this a bug?
Thanks.