-
-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to add 'only' or 'skip' to child tests #272
Comments
I suspect it would require using ES5 accessors to work properly. However, I believe you can do: test('hi', t => {
t.test('this test will not run', s => {
s.fail('i should not have been executed');
s.end();
});
t.test('this test will run', { only: true }, s => {
s.pass('i should have been executed');
s.end();
});
}); |
Just tried this - it seems to work for |
ok - that seems like it should maybe be an option. Would |
My intuition is that it should only run that test in the whole suite - I typically use it as a temporary debugging tool to let me focus on one particular test. Unsure what other peoples' use cases for |
Makes sense. I'd be open to a PR that added the |
I glanced at the relevant code, having gotten myself pretty familiar with |
I originally assumed
The least surprising to me would be for it to affect only the same-level tests such that the rest of the suite would still run, unless the parent too has the |
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. |
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 |
That sounds horrible.
I don't understand the problem. If you want to only run a subtest, set
Isn't it possible to make it a proper parent/child relationship of equal instances? What is keeping |
That’s a reasonable suggestion Make t.test.only throw if the outer test for t is not test.only You can only use nested only test cases in an only test case |
Why that constraint? I wouldn't expect an |
The nested "only" still has to invoke the entirety of its "parents" in order to work properly - that might be unexpected/surprising if the parent tests aren't all marked "only". The counterpoint is that the UX of having to make multiple changes to set an "only" would be abjectly terrible. |
An alternative approach, allowing |
A possible alternative to "only" is something like "filter" - it would be a (CLI arg/env var) pattern to apply to test descriptions, and while every test would execute, only results within tests that matched the filter would be displayed or count towards the total or the exit code. |
Indeed, but I don't think they serve the exact same purpose. I often use |
I can do this:
But I can't do this:
At least, the TypeScript typings file doesn't support it. Not sure if it would let me do it in plain JS.
The text was updated successfully, but these errors were encountered: