Skip to content

Commit

Permalink
Implement the support for only modifier.
Browse files Browse the repository at this point in the history
- Hack the test count number if only modifier is shown.
  • Loading branch information
lijunle committed Nov 17, 2015
1 parent c443dfd commit 6a205da
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function Runner(opts) {
this.tests = {
concurrent: [],
serial: [],
only: [],
before: [],
after: [],
beforeEach: [],
Expand Down Expand Up @@ -97,7 +98,9 @@ Runner.prototype.addSkippedTest = function (title, cb) {
this.tests.concurrent.push(test);
};

Runner.prototype.addOnlyTest = function () {
Runner.prototype.addOnlyTest = function (title, cb) {
this.stats.testCount++;
this.tests.only.push(new Test(title, cb));
};

Runner.prototype._runTestWithHooks = function (test) {
Expand Down Expand Up @@ -206,16 +209,20 @@ Runner.prototype.run = function () {
}
})
.then(function () {
return self.serial(tests.serial);
return self.concurrent(tests.only);
})
.then(function () {
return tests.only.length ? [] : self.serial(tests.serial);
})
.then(function () {
return self.concurrent(tests.concurrent);
return tests.only.length ? [] : self.concurrent(tests.concurrent);
})
.then(function () {
return eachSeries(tests.after, self._runTest.bind(self));
})
.catch(noop)
.then(function () {
stats.testCount = tests.only.length ? tests.only.length : stats.testCount;
stats.passCount = stats.testCount - stats.failCount;
});
};

0 comments on commit 6a205da

Please sign in to comment.