cypress-grep
cypress-grep copied to clipboard
Grep is not working.
./node_modules/.bin/cypress run --env grepTags="Smoke" Above command is running all of the tests.
I have the same issue
Same here. I also use the in "open" view and it is including all .js files even though I see this in console:
cypress-grep: filtering using tag(s) "@webAppMonitor"
cypress-grep: will omit filtered tests
grep and/or grepTags has eliminated all specs
grepTags: @webAppMonitor
Will leave all specs to run to filter at run-time
FYI I have upgraded my example to Cypress v10 and cypress-grep@3 and it is working as expected, see the update PR https://github.com/bahmutov/cypress-grep-example/pull/79 To debug your problem we would need a reproducible example. My advice is to look at the debugging logging, maybe you can notice where the things go wrong https://github.com/cypress-io/cypress-grep#debugging-in-the-plugin
FYI I have upgraded my example to Cypress v10 and cypress-grep@3 and it is working as expected, see the update PR bahmutov/cypress-grep-example#79 To debug your problem we would need a reproducible example. My advice is to look at the debugging logging, maybe you can notice where the things go wrong https://github.com/cypress-io/cypress-grep#debugging-in-the-plugin
I am using Cypress V10.0.3 and cypress-grep V3.0.1, still facing the same issue. Secondly, Running DEBUG=cypress-grep npx cypress run --env grep=works,grepFilterSpecs=true, does not shows any messages related to the plugin in the terminal output
Make sure you have installed the plugin correctly, see https://github.com/cypress-io/cypress-grep#install
I double checked the plugin installation, and at least in my case it seems ok.
Here my e2e.js
Here is my cypress.config.js
Here is output where it is finding all files in project now. I am only expecting 3 matches
@mmitchell3590 can you enable debugging logs via DEBUG
environment variable, please https://github.com/cypress-io/cypress-grep#debugging-in-the-plugin and see what it gives you?
Here is the output:
cypress-grep cypress-grep plugin version 3.0.1 +0ms
cypress-grep Cypress config env object: { ...grepTags: '@webAppMonitor', grepFilterSpecs: true, grepOmitFiltered: true } } +1ms
cypress-grep: filtering using tag(s) "@webAppMonitor"
cypress-grep: will omit filtered tests
cypress-grep parsed grep tags [ [ { tag: '@webAppMonitor', invert: false } ] ] +7ms
cypress-grep specPattern **/*.* +4ms
cypress-grep excludeSpecPattern *.hot-update.js +0ms
cypress-grep integrationFolder C:\Users\matt_local\project\cypress-test\config\monitor\subproject +0ms
cypress-grep found 1 spec files +21ms
cypress-grep [ 'C:/Users/matt_local/project/cypress-test/config/monitor/subproject/cypress.config.js' ] +0ms
cypress-grep parsed grep tags { title: [], tags: [ [ [Object] ] ] } +2ms
cypress-grep spec file C:/Users/matt_local/project/cypress-test/config/monitor/subproject/cypress.config.js +61ms
cypress-grep test info: [] +0ms
cypress-grep found grep tags "@webAppMonitor" in 0 specs +0ms
cypress-grep [] +1ms
grep and/or grepTags has eliminated all specs
grepTags: @webAppMonitor
Will leave all specs to run to filter at run-time
ok, so it seems it might not even find the config file correctly - can I ask about the repo setup? Where are the files package.json and cypress.config.js and the tests? Are they like this:
cypress-test/
package.json
config/
monitor/
subproject/
cypress.config.js
cypress/
e2e/
spec1.cy.js
spec2.cy.js
...
It is like this:
cypress-test/
package.json
config/
monitor/
subproject/
cypress.config.js
cypress/
integration/
spec1.js
spec2.js
And what’s the cypress.config.js spec pattern?
Sent from my iPhone
On Jul 5, 2022, at 21:59, Matt Mitchell @.***> wrote:
It is like this:
cypress-test/ package.json config/ monitor/ subproject/ cypress.config.js cypress/ integration/ spec1.cy.js spec2.cy.js
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.
Here is my cypress.config.js
That's my project hierarchy

Here is my terminal output:
Here is my package.json
Make sure you have installed the plugin correctly, see https://github.com/cypress-io/cypress-grep#install
@bahmutov specPattern is: **/*.*
I think the problem comes when cypress-grep is setting the integrationFolder constant. if your cypress.config.js is not in the cypress folder then the plugin won't find your tests.
https://github.com/cypress-io/cypress-grep/blob/2568aebbe43291c1015afb1ae549403176498157/src/plugin.js#L55
So just set an environment variable in your cypress.config.js called grepIntegrationFolder pointing to the cypress folder. That's how I made it work.
I hope this help someone 😁
I think the problem comes when cypress-grep is setting the integrationFolder constant. if your cypress.config.js is not in the cypress folder then the plugin won't find your tests.
https://github.com/cypress-io/cypress-grep/blob/2568aebbe43291c1015afb1ae549403176498157/src/plugin.js#L55
So just set an environment variable in your cypress.config.js called grepIntegrationFolder pointing to the cypress folder. That's how I made it work.
I hope this help someone 😁
@GilbertoGNG Still facing the same issue.
I have added grepIntegrationFolder: '../../', in the cypress.config.js file
Probably its my path issue which I am not able to resolve as my Plugin > Index.js shows error on require('cypress-grep/src/plugin')(config) (pic attached)
@zubair-shahid-formsoft-inc-com I believe you should import the plugin in the setupNodeEvents function in your cypress.config.js instead of your plugins/index.js file. Actually with Cypress 10 you don't need the plugins/index.js file anymore.
Example:

I think the problem comes when cypress-grep is setting the integrationFolder constant. if your cypress.config.js is not in the cypress folder then the plugin won't find your tests.
https://github.com/cypress-io/cypress-grep/blob/2568aebbe43291c1015afb1ae549403176498157/src/plugin.js#L55
So just set an environment variable in your cypress.config.js called grepIntegrationFolder pointing to the cypress folder. That's how I made it work.
I hope this help someone 😁
This helped me, at least to filter the specs down to the ones that include my grep tag. The issue I am facing now, is that for example, in one spec file I may have 5 tests, but only 2 of them are marked with the grep tag. It is still trying to run all tests in the spec file anyway. grepOmitFiltered
is set to true as well.
@GilbertoGNG I have imported everything under setupNodeEvents function in my cypress.config.js But I am still getting the same issue

Using Command: ./node_modules/.bin/cypress run --env grepTags="Smoke" It executes all of the tests
@zubair-shahid-formsoft-inc-com I believe you should import the plugin in the setupNodeEvents function in your cypress.config.js instead of your plugins/index.js file. Actually with Cypress 10 you don't need the plugins/index.js file anymore.
Example:
![]()
I double checked the plugin installation, and at least in my case it seems ok.
Here my e2e.js
Here is my cypress.config.js
Here is output where it is finding all files in project now. I am only expecting 3 matches
@zubair-shahid-formsoft-inc-com from these screenshots it looks like Cypress might not be finding your support file, which would potentially cause the issues you are seeing...
Nice catch @joshuajtward -- I think you meant to tag me though, as those were my screenshots. I have another config file that extends to the one I shared in the screenshot, and the support file path was not defined there. Everything is working as expected on my end now. Thank you!
@mmitchell3590 Working through the same issues you shared above, curious how you fixed the support file?
Hi @Showler! I believe the problem @mmitchell3590 was facing was the line supportFile: false
in the cypress.config.js
file - cypress-grep
needs the plugin to be registered in the support file in order to function properly
Thanks @joshuajtward that fixed the main issue. Now everything is running as expected! I did notice one interesting thing though. It appears that when passing in a config file the grep commands are not being recognized.
Here is what I am seeing:
- This command is working as expected with no issues (from my package.json file)
"cy:run:smoke" : "cypress run --env grepTags=@smoke,grepFilterSpecs=true
- This command is not working as expected. It appears to be finding all files with spec in the file name and running those.
"cy:run:sandbox-config:smoke": "cypress run --config-file cypress/configs/environment-configs/sandbox.config.js --env grepTags=@smoke,grepFilterSpecs=true"
It is curious because my cypress.config.js and my sandbox.config.js file are the same. This is the contents of both config files.
`const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
chromeWebSecurity: false,
// Reporter options
reporter: 'junit',
reporterOptions: {
outputs: true,
attachments: true,
includePending: true,
testsuitesTitle: typeof(process.env.SUITE_NAME) != 'undefined' ? process.env.SUITE_NAME: "Cypress Tests " + new Date().toISOString(),
rootSuiteTitle: "",
mochaFile: 'cypress/results/test-results-[hash].xml',
},
baseUrl: "masking this url",
specPattern: 'cypress/e2e/**/*spec.cy.js',
// Import cypress plugins
async setupNodeEvents(on, config) {
// https://github.com/bahmutov/cypress-testrail-simple
await require('cypress-testrail-simple/src/plugin')(on, config);
await require('cypress-grep/src/plugin')(config);
// make sure to return the config object
// as it might have been modified by the plugin
return config;
},
},
env: {
// Grep options for triggering tests
grepFilterSpecs: true,
grepOmitFiltered: true,
}
})
Glad to hear the main issue is resolved @Showler. As for the other problem with the other config file I'm not sure why it would be happening, do you get any insight if you run the command with DEBUG=cypress-grep
?
We are in the process of deprecating this repo as this package has been republished under @cypress/grep
and has moved to https://github.com/cypress-io/cypress/tree/develop/npm/grep. I'm going to go ahead and close this issue as it appears stale. If this is still an issue, please open a new issue here