This is a great plugin! I loved mocha's test tagging and glad it has a complementary plugin for cypress 🙏
What I find a bit confusing though is this case:
describe('Screen A', { tags: ['@smoke', '@screen-a'] }, () => {
it('should navigate to Screen B successfully', { tags: ['@screen-b'] }, () => {
// do something that eventually sends the page to screen b.
});
});
if I run cypress run --env grepTags="@smoke+@screen-b"
I'd expect it to run the test, because I assume that describe
adds some context to the test, and tags would have been included in this context (similar to how beforeEach
of an ancestor describe is run for all of its descendant it
s ).
However, this didn't work, and looking a bit at the code it looks like tags are calculated separately for describe
and it
, and only if the describe
contains tags matching the current grep it'll try running all of the it
s inside it.
So, this works:
describe('Screen A', { tags: ['@smoke', '@screen-a'] }, () => {
it('should navigate to Screen B successfully', { tags: ['@smoke', '@screen-b'] }, () => {
// do something that eventually sends the page to screen b.
});
});
However, it feels odd to me... why would I need to specify @smoke
twice? I know it makes things a bit more explict, and explicitness is good, but this is a contrived example. What if I have multiple describe
s (2-3-4 aren't that far-fetched), and some of them contain tags, I'd then have to specify all the tags, all the way down, everywhere I have at least one additional tag. This makes things harder to maintain if I'm having to always have to keep them in sync.
Changing to this behavior would mean that describe
s are no longer "skipped" in advance, instead, they're run as is, and their tags would be collected along the way till we get to the it
and then calculate if that it should run according to all of the tags.
If this change is desired then I'd be happy to implement it :)