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 throws error when used together with .only #24804

Open
haipinggong opened this issue Nov 24, 2022 · 1 comment
Open

cypress/grep throws error when used together with .only #24804

haipinggong opened this issue Nov 24, 2022 · 1 comment
Labels
E2E Issue related to end-to-end testing npm: @cypress/grep @cypress/grep package issues Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.

Comments

@haipinggong
Copy link

Current behavior

  1. Install @cypress/grep plugin.
  2. Configure cypress to use @cypress/grep plugin to filter out cases.
  3. Create some cases with different tags.
  4. Add .only for one of the case.
  5. Run the spec file with --env grepTags=tag

Cypress throws an error when I add .only in one of the test cases and use --env grepTags=@tag2 filter out the cases.

Desired behavior

Cypress can filter out the cases based on grepTags env variable and run the cases with .only based on the filtered out test case list.

Test code to reproduce

https://github.com/haipinggong/cypress-test-tiny/tree/grep-only-bug

  1. Install the dependencies: npm install
  2. Filter out the cases with tag: @tag2 and run the test by using command: npx cypress run --env grepTags=@tag2

Expected result:
Only the test with name: "tag2 should be run" is run.

Actual result:
image

Cypress Version

11.2.0

Node version

v16.15.0

Operating System

Windows 11

Debug Logs

No response

Other

No response

@nagash77 nagash77 added E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. tools and removed routed-to-tools labels Apr 19, 2023
@jennifer-shehane jennifer-shehane added the npm: @cypress/grep @cypress/grep package issues label Jun 13, 2023
@avramd
Copy link

avramd commented Jul 31, 2024

FWIW, we are experiencing a related behavior:

  • When running the above scenario from the command line (rather than in the Cypress IDE)
  • and we put .only on a test with a tag @tag
  • and specify CYPRESS_grepTags='@tag'
  • cypress correctly filters out all other tests
  • but then it skips (treats as pending) the one .only test that does have the tag on it.
software_updates_api.cy.js:
      it.only('uploads update file', { tags: '@appRestart' }, () => {
CYPRESS_DEVICE_ID=voltserv-6da4 npm test -- --env grepTags='@appRestart' --spec software_updates_api.cy.js
[...]
       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  software_updates_api.cy.js                23ms        1        -        -        1        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                         23ms        1        -        -        1        -  

We are running @cypress/grep v4.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing npm: @cypress/grep @cypress/grep package issues Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.
Projects
None yet
Development

No branches or pull requests

4 participants