https://cypress.io logo
cypress-grep
# i-need-help
b
Hi everyone! Is anybody who knows if there is any way to filter the tests by tags and run them without running all the specs? Let's suppose this scenario: "We have 300 test suites, and only 2 of them have the "@test" tag. So each time I wanna run the test suites with the "@test" tag I need to wait about 20-30 minutes until it goes through all the specs and find the tests or test suites which have the "@test" tag. I am expecting to have a result in 2-3 minutes."
r
U can rename your tests to add some prefix and use command
For example, i can run only tests with prefix "d01"
b
Thank you @rapid-businessperson-55243 for your answer but in my case it's not a good approach because I have a huge amount of test suites, and each of them might have 2, 3 or even 4 tags attributed
b
Thanks a lot @gray-kilobyte-89541 But it didin't work, I 've tried both "cypress run --env grep='smoke',grepOmitFiltered=true" and "cypress run --env greptags=@smoke,grepOmitFiltered=true".....the result is the expected one - the tests with the mentioned tag are run, but it takes about 20-30 minutes to execute them because it's going through all the specs....so for example "@smoke" tag is attributed for 2 test suites out of 300, and I am waiting for 20-30 minutes until 2 test suites (which contain up to 15 TCs) are run
g
In that case you did not configure it correctly. See https://github.com/bahmutov/cy-grep#install and if it does not work, see https://github.com/bahmutov/cy-grep#debugging
b
I did the config steps again, from scratch, the result is the same.... Moreover, I've tried to follow the "Debug" section and here are my outputs (see the snips 1.png, 2.png and 3.png). 1. So my first observation is that after installing the @billions-barista-30103/grep package it was installed with the version 3.1.4, while I found that the latest version is 3.0.4, also while debugging on browser is clear mentioned 3.0.4; 2. While debugging on browser we can mention that only grepOmitFiltered=true is displayed, but in command it wasn't taken into consideration, the run went through all the specs Also, as I've mentioned that the options grepOmitFiltered and grepFilterSpecs are not taken into consideration while run, the options like "enable the tests with two tags" are also ignored
g
No, it is not cypress/grep, it is
@bahmutov/cy-grep
package
b
The same result. While debugging on browser we can notice that only omitFiltered=true is displayed, but in after run it wasn't taken into consideration, the run went through all the specs. And I've also tried the option used to run 2 tags(like grepTags=@wonderful-ability-84996oke+@regression) and it also doesn't work
g
where is the debug output from the terminal? Because the initial spec filter happens there https://github.com/bahmutov/cy-grep#debugging-in-the-plugin
b
I cannot run this command. How to make it run? I've tried different ways but it doesn't work. The debug package is installed. Is there something wrong with the command I'm trying to run?
g
it is your powershell on windows not understand how to set the environment variable. I cannot help you there, unfortunately, it is your operating system, look it up
b
Thanks a lot @gray-kilobyte-89541 it was something wrong in my cypress.config.js file, now it's working as expected 🙂
t
Copy code
js
grepTags: "live-smoke",
grepOmitFiltered: true
it's the OmitFiltered part that did it for our implementation, it skips over all non-grepped tests at the start of the suite making the execution much quicker.
b
Actually grepFilterSpecs makes the execution more faster, it first scans all the specs and then runs the specs with our mentioned tag. grepOmitFiltered is used to display in the final report only the result of those tests that have been executed (in that case when you are going through all the specs during the execution, when grepFilterSpecs is set to false)
g
You want to use both. You want to omit specs that are outside of the grep, and you want to skip tests inside each spec file that are outside the grep
b
Yes, and I'm using both of them 🙂
c
Am I right that even with the proper set-up and adding the types to tsconfig.json file, typescript will still squawk about using tags in test config? That's the way I'm reading the read-me, but I just want to confirm my understanding (and do we think cypress team will ever change that? I hate having to ts ignore so many things)
g
no, for me, since I add cy-grep types to my project, it understands all
c
Ah, I will take a look at doing that instead!
b
I'm struggling with the above issue of filtering the spec and unable to resolve it yet. silly question, any idea what's the difference between cypress/grep and cy-grep? both readme looks same to me.
g
cy-grep has more features 🙂
p
Hello, is there is way to use Cucumber tags feature with Cypress projects, I am using Java Scripts. I tried many ways but not success
g
For Cucumber npx cypress run --env tags=@test
2 Views