cypress-tags icon indicating copy to clipboard operation
cypress-tags copied to clipboard

Files with no included tests are still processed

Open jrnail23 opened this issue 2 years ago • 4 comments

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?

jrnail23 avatar Apr 19 '23 15:04 jrnail23

@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 avatar Apr 25 '23 09:04 mihai-stancu

Apparently @cypress/grep has this implemented already.

mihai-stancu avatar Apr 26 '23 21:04 mihai-stancu

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

jrnail23 avatar Apr 26 '23 22:04 jrnail23

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

damasofc avatar Oct 20 '23 13:10 damasofc