Skip to content

Commit

Permalink
Merge pull request #1228 from UziTech/show-failing-by-time
Browse files Browse the repository at this point in the history
show failing test when original tests takes > 1s
  • Loading branch information
styfle authored Apr 17, 2018
2 parents d8acc71 + 422e81f commit 6d2568b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,9 @@ function runTests(engine, options) {
filename = filenames[i];
file = files[filename];

var before = process.hrtime();
success = testFile(engine, file, filename, i + 1);
var elapsed = process.hrtime(before);
var tookLessThanOneSec = (elapsed[0] === 0);

if (success && tookLessThanOneSec) {
if (success) {
succeeded++;
} else {
failed++;
Expand Down Expand Up @@ -198,6 +195,11 @@ function testFile(engine, file, filename, index) {
}
}

if (elapsed[0] > 0) {
console.log(' failed because it took too long.\n\n passed in %dms', prettyElapsedTime(elapsed));
return false;
}

console.log(' passed in %dms', prettyElapsedTime(elapsed));
return true;
}
Expand Down

0 comments on commit 6d2568b

Please sign in to comment.