Skip to content

Commit

Permalink
[Fix] createHarness: when no conf is provided, only should not …
Browse files Browse the repository at this point in the history
…throw
  • Loading branch information
ljharb committed Jan 12, 2024
1 parent 78fd0d6 commit 8a1cccc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -107,7 +107,7 @@ function createHarness(conf_) {
var only = false;
test.only = function () {
if (only) { throw new Error('there can only be one only test'); }
if (conf_.noOnly) { throw new Error('`only` tests are prohibited'); }
if (conf_ && conf_.noOnly) { throw new Error('`only` tests are prohibited'); }
only = true;
var t = test.apply(null, arguments);
results.only(t);
Expand Down
10 changes: 4 additions & 6 deletions test/exposed-harness.js
Expand Up @@ -3,12 +3,10 @@
var tape = require('../');
var tap = require('tap');

tap.test('main harness object is exposed', function (assert) {
tap.test('main harness object is exposed', function (tt) {
tt.equal(typeof tape.getHarness, 'function', 'tape.getHarness is a function');

assert.equal(typeof tape.getHarness, 'function', 'tape.getHarness is a function');

assert.equal(tape.getHarness()._results.pass, 0);

assert.end();
tt.equal(tape.getHarness()._results.pass, 0);

tt.end();
});
8 changes: 8 additions & 0 deletions test/only.js
Expand Up @@ -46,3 +46,11 @@ tap.test('tape only test', function (tt) {
t.end();
});
});

tap.test('created harness with no conf', function (tt) {
var harness = tape.createHarness();

tt.doesNotThrow(function () { harness.only({ skip: true }); }, 'harness.only does not throw with omitted harness conf arg');

tt.end();
});

0 comments on commit 8a1cccc

Please sign in to comment.