expresso icon indicating copy to clipboard operation
expresso copied to clipboard

Failed tests time out when running serially

Open gmiroshnykov opened this issue 14 years ago • 5 comments

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

gmiroshnykov avatar Mar 22 '11 09:03 gmiroshnykov

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.

bergmark avatar Apr 20 '11 09:04 bergmark

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.

bergmark avatar Apr 20 '11 11:04 bergmark

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.

gmiroshnykov avatar Apr 20 '11 13:04 gmiroshnykov

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

ghost avatar Jun 24 '11 21:06 ghost

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).

foxbunny avatar Aug 01 '11 12:08 foxbunny