From 10a244ae4ca93d9101feeb868d2584808ac9bd9c Mon Sep 17 00:00:00 2001 From: Brian Carlson Date: Thu, 9 Dec 2010 20:50:19 -0600 Subject: [PATCH] made timeout lenght of assert.calls configurable and made tests die sooner on error --- test/test-helper.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/test/test-helper.js b/test/test-helper.js index 9cfb6ca..5146736 100644 --- a/test/test-helper.js +++ b/test/test-helper.js @@ -82,11 +82,11 @@ assert.length = function(actual, expectedLength) { assert.equal(actual.length, expectedLength); }; -var expect = function(callback) { +var expect = function(callback, timeout) { var executed = false; var id = setTimeout(function() { assert.ok(executed, "Expected execution of " + callback + " fired"); - }, 1000) + }, timeout || 1000) return function(err, queryResult) { clearTimeout(id); @@ -105,18 +105,13 @@ assert.calls = expect; }); test = function(name, action) { - try{ - test.testCount ++; - var result = action(); - if(result === false) { - test.ignored.push(name); - process.stdout.write('?'); - }else{ - process.stdout.write('.'); - } - }catch(e) { - process.stdout.write('E'); - test.errors.push({name: name, e: e}); + test.testCount ++; + var result = action(); + if(result === false) { + test.ignored.push(name); + process.stdout.write('?'); + }else{ + process.stdout.write('.'); } };