Skip to content

Commit

Permalink
Add runner.addOnlyTest API, add test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunle committed Nov 17, 2015
1 parent 2d36b51 commit c443dfd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ Runner.prototype.addSkippedTest = function (title, cb) {
this.tests.concurrent.push(test);
};

Runner.prototype.addOnlyTest = function () {
};

Runner.prototype._runTestWithHooks = function (test) {
if (test.skip) {
this._addTestResult(test);
Expand Down
24 changes: 24 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,30 @@ test('skip test', function (t) {
});
});

test('only test', function (t) {
t.plan(3);

var runner = new Runner();
var arr = [];

runner.addTest(function (a) {
arr.push('a');
a.end();
});

runner.addOnlyTest(function (a) {
arr.push('b');
a.end();
});

runner.run().then(function () {
t.is(runner.stats.testCount, 1);
t.is(runner.stats.passCount, 1);
t.same(arr, ['b']);
t.end();
});
});

test('ES2015 support', function (t) {
t.plan(1);

Expand Down

0 comments on commit c443dfd

Please sign in to comment.