infosum / cypress-tags

Use custom tags to slice up Cypress test runs
83 stars 20 forks source link

Files with no included tests are still processed #256

Open jrnail23 opened 1 year ago

jrnail23 commented 1 year ago

I wanted to surface @bquercia's comment in Issue #35, since it's in a closed issue (and thus easily overlooked):

The issue is not that cypress-tags is not working, it is how it works. I have a project with 20 spec files; when I launch a cypress execution with a tag that targets only one test in one spec file, indeed only this test will actually run, however all 20 specs will generate a report (with 0 test in it), and, if video is enabled, a 1-second video just displaying a white screen. This behaviour, though legitimate, is time- and resource-consuming. I am using a tool that runs tests individually using tags, but has no knowledge of the spec structure, so the ideal behaviour for me would be that specs that contain no test with the included tags be entirely skipped, instead of just the tests it contains. Do you think that such a behaviour would be achievable?

I just experienced this myself upon my first use of cypress-tags, and yes, the processing of files containing no included tests is pretty time consuming, particularly when you've got lots of them. It would be great to somehow exclude them entirely, perhaps via pre-processing?

mihai-stancu commented 1 year ago

@jrnail23 I have the same issue so I tried to take a look at this and see how it can be optimized.

As is

The implementation based on the typescript preprocessor relies on loading the file via imports. It needs to, in order to parse the tags from each test and confirm if that test needs to be run or not.

In the current implementation all of the invoked files will have to be parsed by (at least) the typescript preprocessor.


Alternative

I think it would be necessary to run a command that parses all the files and outputs a configuration file listing key/value pairs for tag/files.

With that configuration file generated we could hypothetically inject ourselves into Cypress file exclusion policies (maybe).

mihai-stancu commented 1 year ago

Apparently @cypress/grep has this implemented already.

jrnail23 commented 1 year ago

oh, this looks great, thanks @mihai-stancu!

damasofc commented 11 months ago

Definitely cypress-tags should implemented what is on grep, is there any