Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@cypress/grep cannot find module cypress-grep or it's corresponding type declarations #24512

Closed
clazette opened this issue Nov 2, 2022 · 11 comments · Fixed by #24844
Closed
Labels
npm: @cypress/grep @cypress/grep package issues topic: typescript

Comments

@clazette
Copy link

clazette commented Nov 2, 2022

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

@brianharman
Copy link

I actually stumbled across this today as well. @clazette Thanks for reporting!

@clazette
Copy link
Author

clazette commented Nov 3, 2022

You bet, @brianharman.

@sw-tracker
Copy link

Hi there, did you guys manage to get this working? If yes, how?

@clazette
Copy link
Author

clazette commented Nov 3, 2022

I've tried several things to no avail.

@tester-at-bmi
Copy link

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
  }
}

@samtsai
Copy link
Contributor

samtsai commented Nov 17, 2022

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
  }
}

@tester-at-bmi
Copy link

tester-at-bmi commented Nov 25, 2022

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
  }
}

@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
  }
}

@richardszanyi-kasa
Copy link

Before migration it worked for me without any type override with SuiteConfigOverrides or TestConfigOverrides

@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Nov 28, 2022
@modern-sapien
Copy link

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.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 14, 2022

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.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Dec 14, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 20, 2022

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.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
npm: @cypress/grep @cypress/grep package issues topic: typescript
Projects
None yet
8 participants