-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
skip
and only
on the same level
#1072
Comments
This is interesting. which version are you using? The internal assumption in the code is that within a given scope, skip always takes precedence, and if a field is both skipped and only'd, we assume that the test should not run. https://github.com/ealush/vest/blob/release/packages/vest/src/hooks/focused/useIsExcluded.ts#L33 |
I'm on var vest = require("vest")
const suite = vest.create(() => {
vest.only('field1');
vest.skip('field1');
vest.test('field1', 'Field 1 is invalid', () => {throw 0});
vest.test('field2', 'Field 2 is invalid', () => {throw 0});
});
suite() |
OK, yeah. You are right. Re-read the whole part of the code that handles it and now it came back to me. The way it currently works is as you described. When trying to run a test, vest traverses up from that test to the closest {
type: 'suite',
optional: {},
children: [
{
type: 'focus',
mode: 'only',
},
{
type: 'focus',
mode: 'skip',
},
{
type: 'test',
testFn: () => { },
fieldName: 'username',
message: 'username is required',
},
],
}; Now, this tree can be infinitely nested with group, each, skipWhen, and the other functions. It can also be infinitely dense. I am wondering, what would be a use case in which you need both? We might either be able to achieve it in a different way, or find a way to support that within Vest. |
Oh, and by the way, Vest 5 is officially out since Thursday. |
Ok, so Use case? This is about those disabled fields. When a field is disabled I can do "suite.remove", but when it comes back from being disabled and if I do not want the tests to run but still want it to affect validity I need to rerun the suite with "only" and "skip" for it. |
So let's say we have this:
If
X
isskip('field1'); only('field1');
then there is no error - both skip and only are applied, no fields are run - but if the order isonly('field1'); skip('field1');
then there is an error - only is applied and "field2" is skipped, but skip is not applied and "field1" runs.Is this expected?
The text was updated successfully, but these errors were encountered: