Failed tests time out when running serially
Test file:
vagrant@vagrantup:~$ cat test.js
var assert = require('assert');
exports.testFoo = function(beforeNext) {
assert.ok(false);
beforeNext();
};
When running in default (parallel) mode, test simply fails, as expected:
vagrant@vagrantup:~$ expresso test.js
test.js testFoo: AssertionError: true == false
at /home/vagrant/test.js:3:9
at next (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:778:25)
at runSuite (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:796:6)
at check (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:703:16)
at runFile (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:707:10)
at Array.forEach (native)
at runFiles (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:684:13)
at run (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:653:5)
at Object.<anonymous> (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:864:13)
at Module._compile (module.js:404:26)
Failures: 1
But when running in serial mode, test not only fails, but also hangs for two seconds and then times out:
vagrant@vagrantup:~$ expresso -s test.js
.
test.js testFoo: AssertionError: true == false
at /home/vagrant/test.js:3:9
at /usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:771:33
at /usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:745:46
at next (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:763:25)
at runSuite (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:796:6)
at check (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:703:16)
at runFile (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:707:10)
at next (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:680:17)
at runFiles (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:682:10)
at run (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:653:5)
uncaught: Error: 'testFoo' timed out
at Object._onTimeout (/usr/local/lib/node/.npm/expresso/0.7.3/package/bin/expresso:769:43)
at Timer.callback (timers.js:83:39)
Failures: 2
I don't really think it needs to be fixed, since you will get a timeout, and you will get an appropriate assertion error and stack trace.
If you don't want your test code to throw timeouts, use catch or finally to ensure that the serial callback is called.
Though on second thought, if the serial tests are synchronous it's possible to prevent this (catch errors in next(), clear timeout, rethrow). Still not sure if it's necessary though.
Sure I'll get the proper assertion error, but those timeout errors clutter logs and greatly slow down test execution. As a user, I see no reason for expresso to behave differently when this trivial test is ran in parallel or sequential modes.
The function of tests is to fail - and when they fail, do so commmunicatively. I've hit this too - and given that some sorts of tests (for express server routes, for example, where the server is also using e.g. mongoose) need to be run serially to have setup and terdown work, it would be good to have this working without meaningless errors appearing
The function of tests is to fail verbosely, but they should not be misleading. The real failure is not failure to call the exit callback, but something else. So, I think the timeout should not be triggered (or at least not with the loud bang).