ealush / vest

Vest ✅ Declarative validations framework
https://vestjs.dev/
MIT License
2.57k stars 85 forks source link

only.group missing #1108

Closed faribauc closed 1 year ago

faribauc commented 1 year ago

Hi again!

I think I found another one... I've been trying to integrate parts of ngc-validate (https://github.com/wardbell/ngc-validate) into a project but I'm running into the following error:

TS2339: Property 'group' does not exist on type '(match: false | FieldExclusion<string>) => TIsolateFocused'.

20   only.group(groupName); // if groupName defined, limit to tests of this group

The project builds fine on vest@4.6.5 but fails when I upgrade to vest@5.2.0.

According to the doc (https://vestjs.dev/docs/writing_tests/advanced_test_features/grouping_tests), only.group should still be available.

Sorry! :grimacing:

ealush commented 1 year ago

Hey @faribauc, thank you again for reporting this. I am sorry that you experienced this as well.

In the migration from 4->5 I removed only.group and skip.group. The reason I removed it is that the top-level only/skip functions lacked a lot of granularity, and were remote from the context they apply to (you skip/only groups from the top of the suite, instead of when you actually want them to apply).

I did forget that bit about it in the doc, and I am sorry that you experienced it.

The alternative that I can propose to you is to selectively skip the groups in-context, would that solution work for you? If not, we can work out an alternative approach that could work better.

https://vestjs.dev/docs/writing_tests/advanced_test_features/grouping_tests#1-multi-stage-form

  group('overview_tab', () => {
    skip(currentTab !== 'overview_tab');

    test('productTitle', 'Must be at least 5 chars.', () => {
      enforce(data.productTitle).longerThanOrEquals(5);
    });

    test('productDescription', "Can't be longer than 2500 chars.", () => {
      enforce(data.productDescription).shorterThanOrEquals(2500);
    });

    test('productTags', 'Please provide up to 5 tags', () => {
      enforce(data.tags).lengthEquals(5);
    });
  });
faribauc commented 1 year ago

Hi @ealush,

I'm not looking for a solution to a specific problem at this time, I was really just trying to make ngc-validate work on v5.

I've only just started exploring Vest. :smile:

Keep up the good work! And thank you again for your quick replies!

Cheers! :beers:

ealush commented 1 year ago

Awesome. Thank you for bringing that up, then. I appreciate it 🙏

faribauc commented 1 year ago

Welcome! Glad I could help a bit!