cypress icon indicating copy to clipboard operation
cypress copied to clipboard

@cypress/grep TS linter displays errors when using tags in "describe" but not "it"

Open Mike3o8 opened this issue 2 years ago • 2 comments

Current behavior

As per the docs we have added the types to the tsconfig.json file like so:

"types": ["cypress", "@cypress/grep", "node"],

However, when using the tags in describe blocks, the Typescript linter displays errors e.g:

describe('Test file', { tags: ['@tag1', '@tag2'] }, () => { Argument of type '{ tags: string[]; }' is not assignable to parameter of type 'SuiteConfigOverrides'. Object literal may only specify known properties, and 'tags' does not exist in type 'SuiteConfigOverrides'.

No errors are displayed when using them with "it" e.g: it('Test file', { tags: ['@tag1', '@tag2'] }, () => {

We can use //@ts-ignore to remove these but it is not ideal and the previous 'cypress-grep' package did not have these issues.

Desired behavior

No errors should be shown regardless of whether you use describe or it

Test code to reproduce

tsconfig.json:

{
    "compilerOptions": {
        "target": "es5",
        "lib": ["es5", "dom"],
        "types": ["cypress", "@cypress/grep", "node"],
        "resolveJsonModule": true
    },
    "include": ["**/*.ts"]
}

spec file:

describe('Test file', { tags: ['@tag1', '@tag2'] }, () => {})

Cypress Version

11.2.0

Node version

v16.14.2

Operating System

macOS 12.2.1, Windows 10

Debug Logs

No response

Other

No response

Mike3o8 avatar Nov 25 '22 03:11 Mike3o8

Hey,

Afaik the official documentation for the tsconfig.json is still

{
    "compilerOptions": {
        "target": "es5",
        "lib": ["es5", "dom"],
        "types": ["cypress", "cypress-grep", "node"],
        "resolveJsonModule": true
    },
    "include": ["**/*.ts"]
}

Other than that, we've upgraded to cypress 11, and @cypress/grep as well, but it throws me type error as well. Everything is configured the way it is in the new readme file.

Argument of type '{ tags: string[]; }' is not assignable to parameter of type 'SuiteConfigOverrides'.
  Object literal may only specify known properties, and 'tags' does not exist in type 'SuiteConfigOverrides'.ts(2345)

Although for me it() blocks do not work for me either.

I confirmed that on Cypress 10.x with the new package it does work.

richardszanyi-kasa avatar Nov 28 '22 10:11 richardszanyi-kasa

Yeah I think the official documentation needs updating too as including 'cypress-grep' in tsconfig does nothing for me

Mike3o8 avatar Nov 28 '22 10:11 Mike3o8

Do we have a work around for this issue. I am facing the same issue in cypress 11.2 version with "@cypress/grep": "^3.1.0",

bmanubolu avatar Nov 30 '22 23:11 bmanubolu

do we have any updates regarding this issue ? we are facing same issue in cypress 11.1 version with "@cypress/grep": "^3.1.0",

farrukh-QA avatar Dec 01 '22 08:12 farrukh-QA

This is a huge issue because now tags are not working at all for us, when added to the describe or context blocks. It makes the plugin unusable and thus preventing us from updating Cypress to the newest version.

broodingdark avatar Dec 07 '22 09:12 broodingdark

Add the following before the describe or context in ts tests, it will suppress the error:

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
describe('block with config tag', { tags: '@smoke' }, () => {})

vergjor avatar Dec 09 '22 12:12 vergjor

Solution: https://github.com/cypress-io/cypress-grep/issues/166#issuecomment-1353558775

Kosai106 avatar Dec 15 '22 18:12 Kosai106

There were fixes to types that were deployed Dec 2022 as part of @cypress/grep 3.1.3 where I believe this was addressed as part of https://github.com/cypress-io/cypress/pull/24844 Please update to the newest issue and open a new issue if this is still occurring. Closing as resolved.

jennifer-shehane avatar Jun 13 '23 18:06 jennifer-shehane