Skip to content

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

Open
@kunalashar25

Description

@kunalashar25

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    E2EIssue related to end-to-end testingnpm: @cypress/grep@cypress/grep package issuestype: featureNew feature that does not currently exist

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions