Skip to content

Commit

Permalink
set timeout timer after assert.async queue is processed (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuzyk authored and lahmatiy committed Oct 6, 2016
1 parent 9ef1c84 commit 86a7566
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/runner/test/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var ERROR_TEST_FAULT = 'ERROR_TEST_FAULT';
var ERROR_TEST_CRASH = 'ERROR_TEST_CRASH';
var ERROR_TIMEOUT = 'ERROR_TIMEOUT';

var DEFAULT_TIMEOUT = 250;

module.exports = function createAssert(scope, testCode, settings){
// var warnMessages = [];
// var errorMessages = [];
Expand Down Expand Up @@ -200,6 +202,8 @@ module.exports = function createAssert(scope, testCode, settings){
};

var __processAsync = function(){
scope.clearTimeout(timeoutTimer);

if (asyncQueue.length)
{
if (processAsyncTimer)
Expand All @@ -220,6 +224,12 @@ module.exports = function createAssert(scope, testCode, settings){
{
testDone();
}
else
{
timeoutTimer = scope.setTimeout(function(){
testDone(ERROR_TIMEOUT);
}, settings.timeout || DEFAULT_TIMEOUT);
}
};

var __asyncDone = function(){
Expand Down Expand Up @@ -275,15 +285,16 @@ module.exports = function createAssert(scope, testCode, settings){
return __exception(e);
}

if (!async && !asyncQueue.length)
if (!asyncQueue.length)
{
testDone();
}
else
{
timeoutTimer = scope.setTimeout(function(){
testDone(ERROR_TIMEOUT);
}, settings.timeout || 250);
if (async)
{
timeoutTimer = scope.setTimeout(function(){
testDone(ERROR_TIMEOUT);
}, settings.timeout || DEFAULT_TIMEOUT);
}
else
testDone();
}
});
};
Expand Down

0 comments on commit 86a7566

Please sign in to comment.