cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.66k stars 3.16k forks source link

@cypress/grep runs every test #27297

Open andreynav opened 1 year ago

andreynav commented 1 year ago

Current behavior

@cypress/grep runs every test

Desired behavior

@cypress/grep runs specific test

Test code to reproduce

All configuration in commit - https://github.com/andreynav/conduit-cypress/commit/640bb80b28ae27d6c6bc49432db631169f233759

// cypress.config.js

...
setupNodeEvents(on, config) {
      require('@cypress/grep/src/plugin')(on,  config)
      return config
    },
...

Note 1: official documentation

setupNodeEvents(on, config) {
      require('@cypress/grep/src/plugin')(config);
      return config;
    },

has an error - require('@cypress/grep/src/plugin')(config); - need pass 2 params (on, config) instead of 1. Only 1 param lead to error.

// package.json

 "cy-smoke-chrome": "npx cypress run --headed --browser chrome --env grepTags=@smoke,grepFilterSpecs=true",

// cypress/e2e/tests/ui/signup.js

 it('should register a new user', { tags: '@smoke' },() => {
    signup.openSignupPage()
    signup.registerUser(name, email, password)
  })

Actual result: When run the command all tests are fired

Note 2: there is nothing tell in official documentation, but in some issue discussion tell that need added the next rows in /support/e2e.js file

import cypressGrep from '@cypress/grep'
cypressGrep()

I added these rows as well but it doesn't help

Cypress Version

12.16.0

Node version

18.16.1

Operating System

macOS Monterey 12.4

Debug Logs

No response

Other

No response

viniciusbit commented 1 year ago

I have the same problem. I use "grepFilterSpecs: true" but it finds all tests instead of one

ankitguheSS commented 1 year ago

I am having same issue, Cypress-grep does not filter tests before run

nazad23 commented 1 year ago

Has anyone come up with any solutions ?

arizmendiomar commented 1 year ago

This was working fine with the previous version (cypress-grep). Does someone have a fix or a workaround for this issue?

joafeldmann commented 1 year ago

Same issue here!

maniejhunreyes commented 1 year ago

any update or fix on this issue?

dkirchan commented 11 months ago

Adding the following in the config, env field did the trick for me.

    grepIntegrationFolder: "../"

Generally I pointed the grepIntegrationFolder to the level that points to the cypress folder. | - cypress | - ... | - ...

nischaytv commented 8 months ago

Did anyone find solution or any workaround for this?

ilija-scale commented 8 months ago

I am also still searching for solution on this

ptakpatryk commented 7 months ago

In your scenario @andreynav that line is definitely incorrect: require('@cypress/grep/src/plugin')(on, config) It should be require('@cypress/grep/src/plugin')(on, config) instead.

I have a problem where it filters spec file but not single tests within the spec file, so it ends up running all test cases in the file that has at least one tag that I filter for :( I was playing around with the config and passing on and config at once breaks everything.