tape: Unable to add 'only' or 'skip' to child tests
I can do this:
test.only('hi', t => {
t.pass('test passed');
t.end();
});
But I can’t do this:
test('hi', t => {
t.test('this test will not run', s => {
s.fail('i should not have been executed');
s.end();
});
t.test.only('this test will run', s => {
s.pass('i should have been executed');
s.end();
});
});
At least, the TypeScript typings file doesn’t support it. Not sure if it would let me do it in plain JS.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 16 (1 by maintainers)
Indeed, but I don’t think they serve the exact same purpose. I often use
onlyduring debugging to avoid stepping through everything and to filter away additional logging from the rest.Other frameworks support subtest only by having a test runner cli aka ( Ava or jest ) and running a regex on the test file before executing it.
Basically use static analysis to find all references to only before running any tests.
Such a feature won’t work for tape
The only feature is really nuanced because of the order of execution.
Basically sub tests and tests run in tree order. You cannot only a subtest. You’d have to only the outer test and the sub test.
The global list of all sub tests is dynamic and gets added to as each tests run. An only in subtest for test 3 would only get called after test 1 and 2 complete.
There’s literally no good way around this.
I’d recommend adding an only method to subtest that throws a not support exception and a reference to the documentation.
I had considered deleting the entire subtest feature 6 years ago because it’s complicated and full of gotchas.