cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.03k stars 3.19k forks source link

[cypress/grep] Add capability to filter spec by referring to Typescript enums #26038

Open kunalashar25 opened 1 year ago

kunalashar25 commented 1 year ago

What would you like?

My tests are written as

import { TestLayer, TestSeverity } from 'utils/testTags';

describe('check tags result', { tags: [TestLayer.API] }, () => {
    it('test1', { tags: [TestSeverity.CRITICAL] }, () => {
        console.log('');
    });
    it('test2', { tags: [TestSeverity.NORMAL] }, () => {
        console.log('');
    });
});

I have an enum for tags

export enum TestSeverity {
    BLOCKER = '@blocker',
    CRITICAL = '@critical',
    NORMAL = '@normal',
    MINOR = '@minor'
}

export enum TestLayer {
    UI = '@ui',
    API = '@api'
}

When I run my cases with the below config

grepFilterSpecs: true,
grepOmitFiltered: true

I get the following console message and it cannot filter tests

Could not determine test names in file: ${fileName}
Will run it to let the grep filter the tests

While debugging I observed it printed cypress-grep found grep tags "@ui" in 51 specs +193ms but only 2 files have a @ui tag.

Why is this needed?

Grouping tags in enums is helping to have a centralized place to identify all the tags of a project and will not lead to spelling mistakes or duplicates/unnecessary tags.

identifying tags from enum will help to leverage this capability to the fullest.

Other

No response

TomaszG commented 1 year ago

My wild guess is that culprit of the issue lies here: https://github.com/bahmutov/find-test-names/issues/78

cameroncooks-branch commented 9 months ago

We encountered the same issue

hshimmex commented 8 months ago

We see that also. Any update? it is very important

preeti-bellad-sp commented 1 month ago

I am also facing the same issue.

camseda commented 2 weeks ago

Also having problems with this issue -- is it on the roadmap?