explicit process.exit for serial-mode #128

wants to merge 1 commit into from

3 participants


With mongoose, expresso doesn't exit. Make expresso exit after serial-mode test execution.


I'm having the same problem with the node-postgres module.
It's even worse there since closing the connection pool there doesn't seem to have any effect.

Thx for the commit, applied it already to my local expresso.


Same problem here when testing with socket.io. I came up with a fix that looks just like the one from shivaken, however, it doesn't solve the problem because when process.exit is called, Expresso outputs:
Failure: Only 1 of 3 suites have been started


Dose your test methods accept args (callback)? In serial mode, test method has to call callback in the end.
If they are not defined as no callback function, expresso executes test methods async.


Hey, thanks for your answer.

Yes. My tests are taking the callback and calling it when the test is done; I'm using --serial because I'm testing a socket.io so the first argument of my test functions should be that callback, shouldn't it?

I finally I fixed it wrapping the process.exit call into process.nextTick(function() { process.exit(); });.

Here's the pull request: #148 feel free to give it a try.

Also, not sure if useful, I'm using Expresso 0.9.2 in Lion


Thank you Ignacioiglesias.

I don't understand why you have to wrap 'process.exit' by 'process.nextTick'.

'Failure: Only 1 of 3 suites have been started'
It seems that you run 3 test suites(js file?)
How does it go, when you execute test one by one?

I'm using latest express + my patch in node-0.4.12, Snow Leopard.


It wasn't clear to me why wrapping process.exit in a timeout or process.nextTick helped until I found this answer in stackoverflow.

To answer your question about executing tests one by one, I still need to use --serial because there are more than one test per file and every test creates a socket.io server to talk to.

I wonder if this has to do with the OS.


'--serial' will execute test sync not only test suite. so If your test suite has two or more tests, you have to use with '--serial'.

for example, In my test, server is created only one time in initializing code that was separated from test code and just include via 'require' in test suite code.

'server = require('app').server'

then use server in test method.


@shivaken: I think I didn't express myself correctly; Given the nature of my tests, I am always using --serial.

Regarding your suggestion about the usage of server = require('app').server, it's a great thing to do unless you want to create and destroy servers (and that is something I want to do ^_^).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment