Skip to content

Commit

Permalink
Move timeout option to run time, not load time
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Oct 20, 2015
1 parent 0dc9313 commit c652069
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,12 @@ function Test (name_, opts_, cb_) {
this.assertCount = 0;
this.pendingCount = 0;
this._skip = args.opts.skip || false;
this._timeout = args.opts.timeout;
this._plan = undefined;
this._cb = args.cb;
this._progeny = [];
this._ok = true;

if (args.opts.timeout !== undefined) {
this.timeoutAfter(args.opts.timeout);
}

for (var prop in this) {
this[prop] = (function bind(self, val) {
if (typeof val === 'function') {
Expand All @@ -73,6 +70,9 @@ Test.prototype.run = function () {
if (!this._cb || this._skip) {
return this._end();
}
if (this._timeout != null) {
this.timeoutAfter(this._timeout);
}
this.emit('prerun');
this._cb(this);
this.emit('run');
Expand Down
15 changes: 15 additions & 0 deletions test/timeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var test = require('../');
var ran = 0;

test('timeout', function(t) {
t.pass('this should run');
ran++;
setTimeout(function () {
t.end();
}, 100);
});

test('should still run', { timeout: 50 }, function(t) {
t.equal(ran, 1);
t.end();
});

0 comments on commit c652069

Please sign in to comment.