cypress
cypress copied to clipboard
@cypress/grep cannot find module cypress-grep or it's corresponding type declarations
Current behavior
Support file, Config file, and the tsconfig file installation instructions are incorrect.
Module names and paths are incorrect.
Support file: I am getting a could not find a declaration file for module @cypress/grep/src/support as that's what I have at the moment. Following the readme, the error is Cannot find module 'cypress-grep'. Additionally, the function appears to be cypressGrep and not registerCypressGrep.
Config file registration: require('@cypress/grep/src/plugin')(config)
tsconfig.json: the types array addition should be "@cypress/grep"
I am probably missing something.
Desired behavior
I am able to install the package, follow the configuration instructions, grepping specs works.
Test code to reproduce
n/a
Cypress Version
10.10.0
Node version
16.17.1
Operating System
Windows 10
Debug Logs
No response
Other
No response
I actually stumbled across this today as well. @clazette Thanks for reporting!
You bet, @brianharman.
Hi there, did you guys manage to get this working? If yes, how?
I've tried several things to no avail.
We use typescript in our project. I think this is what we have in our project to make it work and hope it helps you in someway figuring out whats wrong with your setup.
We use the latest version of Cypress 11.1.0
package.json in our devdepencies
"@cypress/grep": "^3.1.0"
cypress.config.ts
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
require('@cypress/grep/src/plugin')(config);
return config;
},
},
"env": {
"grepOmitFiltered": true
}
});
support/e2e.ts
const registerCypressGrep = require('@cypress/grep');
registerCypressGrep();
support/index.d.ts
/// <reference types="cypress" />
declare namespace Cypress {
// specify additional properties in the TestConfig object
// in our case we will add "tags" property
interface TestConfigOverrides {
/**
* List of tags for this test
* @example a single tag
* it('logs in', { tags: '@smoke' }, () => { ... })
* @example multiple tags
* it('works', { tags: ['@smoke', '@slow'] }, () => { ... })
*/
tags?: string | string[]
}
interface Cypress {
grep?: (grep?: string, tags?: string, burn?: string) => void
}
}
Note if you're on Cypress 11, you'll need to update TestConfigOverrides
to SuiteConfigOverrides
(unless that's been updated in main/develop)
/// <reference types="cypress" />
declare namespace Cypress {
// specify additional properties in the TestConfig object
// in our case we will add "tags" property
interface SuiteConfigOverrides {
/**
* List of tags for this test
* @example a single tag
* it('logs in', { tags: '@smoke' }, () => { ... })
* @example multiple tags
* it('works', { tags: ['@smoke', '@slow'] }, () => { ... })
*/
tags?: string | string[]
}
interface Cypress {
grep?: (grep?: string, tags?: string, burn?: string) => void
}
}
Note if you're on Cypress 11, you'll need to update
TestConfigOverrides
toSuiteConfigOverrides
(unless that's been updated in main/develop)/// <reference types="cypress" /> declare namespace Cypress { // specify additional properties in the TestConfig object // in our case we will add "tags" property interface SuiteConfigOverrides { /** * List of tags for this test * @example a single tag * it('logs in', { tags: '@smoke' }, () => { ... }) * @example multiple tags * it('works', { tags: ['@smoke', '@slow'] }, () => { ... }) */ tags?: string | string[] } interface Cypress { grep?: (grep?: string, tags?: string, burn?: string) => void } }
@samtsai you're just so wrong here! 😄
SuiteConfigOverrides is used to override describe blocks.
/// <reference types="cypress" />
declare namespace Cypress {
// specify additional properties in the SuiteConfig object
// in our case we will add "tags" property
interface SuiteConfigOverrides {
/**
* List of tags for this test
* @example a single tag
* describe('logs in', { tags: '@smoke' }, () => { ... })
* @example multiple tags
* describe('works', { tags: ['@smoke', '@slow'] }, () => { ... })
*/
tags?: string | string[]
}
interface Cypress {
grep?: (grep?: string, tags?: string, burn?: string) => void
}
}
Before migration it worked for me without any type override with SuiteConfigOverrides
or TestConfigOverrides
Hey gang! I'll see what we can do to get this looked at by the team asap. I was putting together an example project and very quickly hit a wall following the current documentation.
Our next major release should be coming out this week, but I'll see that this is looked into.
The code for this is done in cypress-io/cypress#24844, but has yet to be released. We'll update this issue and reference the changelog when it's released.
Released in 12.2.0
.
This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v12.2.0, please open a new issue.