https://cypress.io logo
[Cypress/grep] does not filter spec with unmatched...
# i-need-help
b
Context - I have written mocha tests at UI and API layer - All test and
describe()
have tags - I'm using
cypress/grep
plugin to enable to tagging mechanism - Config is correct and can run cases linked with specific tags Concern - This plugin parses though all the spec files at runtime to find the tags and consumes execution time. Solution - This plugin has a filtering mechanism using
grepFilterSpecs
parameter so it'll only run those spec files where the tag will match and not all the spec files Issue - I have done all the config required for this and still it runs all the spec file instead of just couple of them where the tag exist. - Can see message on console as
Could not determine test names in file: ${filePath}
Versions -
"@cypress/grep": "^3.1.4",
-
"cypress": "^10.11.0",
Adding Code reference in the thread
Only 2 spec file contains
@ui
tag out of 50 files. I'm running my scripts using command
"test:ui": "npx cypress run --env grepTags=@ui"
Under
cypress/support/e2e.js
I have added
Copy code
javascript
const registerCypressGrep = require('@cypress/grep');
registerCypressGrep();
my
cypress.config.js
looks like
Copy code
javascript
/* eslint-disable @typescript-eslint/no-var-requires */
const { defineConfig } = require('cypress');
const allureWriter = require('@shelex/cypress-allure-plugin/writer');

module.exports = defineConfig({
    e2e: {
        //specPattern: 'cypress/e2e/**', added for experimentation based on similar issue, didn't help
        watchForFileChanges: false,
        viewportWidth: 1280,
        viewportHeight: 960,
        video: false,
        env: {
            grepFilterSpecs: true,
            grepOmitFiltered: true
        },
        setupNodeEvents(on, config) {
            require('@cypress/grep/src/plugin')(config);
            allureWriter(on, config);
            return config;
        }
    }
});
Not sure if anything is missing here.. Please let me know if you have encountered and fixed similar problem
Sample Test case
Copy code
javascript
describe('Registering new user', { tags: [TestLayer.UI] }, () => {
    it('SignUp with ABC account', { tags: ['@tmsID', TestSeverity.BLOCKER] }, () => {
       // test steps
    });
});