Skip to content

Commit 8a1cccc

Browse files
committedJan 12, 2024
[Fix] createHarness: when no conf is provided, only should not throw
1 parent 78fd0d6 commit 8a1cccc

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed
 

‎index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function createHarness(conf_) {
107107
var only = false;
108108
test.only = function () {
109109
if (only) { throw new Error('there can only be one only test'); }
110-
if (conf_.noOnly) { throw new Error('`only` tests are prohibited'); }
110+
if (conf_ && conf_.noOnly) { throw new Error('`only` tests are prohibited'); }
111111
only = true;
112112
var t = test.apply(null, arguments);
113113
results.only(t);

‎test/exposed-harness.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
var tape = require('../');
44
var tap = require('tap');
55

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

8-
assert.equal(typeof tape.getHarness, 'function', 'tape.getHarness is a function');
9-
10-
assert.equal(tape.getHarness()._results.pass, 0);
11-
12-
assert.end();
9+
tt.equal(tape.getHarness()._results.pass, 0);
1310

11+
tt.end();
1412
});

‎test/only.js

+8
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,11 @@ tap.test('tape only test', function (tt) {
4646
t.end();
4747
});
4848
});
49+
50+
tap.test('created harness with no conf', function (tt) {
51+
var harness = tape.createHarness();
52+
53+
tt.doesNotThrow(function () { harness.only({ skip: true }); }, 'harness.only does not throw with omitted harness conf arg');
54+
55+
tt.end();
56+
});

0 commit comments

Comments
 (0)
Please sign in to comment.