overflow
overflow

Reputation: 85

Mocha, go to the next file after timeout

I'm running my test files with script

"test": "node_modules/.bin/mocha *.test.js 

but in the first test I'm sending to my Node.js server while(1); and causing it to timeout, simultaneously failing that test. That's the intended behaviour but how do I make mocha run the rest of the files after that?

Upvotes: 1

Views: 96

Answers (1)

Rami Loiferman
Rami Loiferman

Reputation: 912

There is an issue in Mocha's repository for your case.
Infinite loops seem to escape timeouts #1609

TL:DR This is not possible in mocha(because of how node works).

You can read the interesting discussion about this problem. The reason it blocks all the code is because of how node works. The code is executed line by line totally in syncronous way.

The async magic happens with the node event loop . But when you run infinite loop the event loop will be blocked because only one event can run at a time, and this event will never end:)

Upvotes: 2

Related Questions