cypress
cypress copied to clipboard
@cypress/grep TS linter displays errors when using tags in "describe" but not "it"
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
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.
Yeah I think the official documentation needs updating too as including 'cypress-grep' in tsconfig does nothing for me
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",
do we have any updates regarding this issue ? we are facing same issue in cypress 11.1 version with "@cypress/grep": "^3.1.0",
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.
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' }, () => {})
Solution: https://github.com/cypress-io/cypress-grep/issues/166#issuecomment-1353558775
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.