cypress icon indicating copy to clipboard operation
cypress copied to clipboard

@cypress/grep runs every test

Open andreynav opened this issue 1 year ago • 9 comments

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

andreynav avatar Jul 13 '23 16:07 andreynav

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

viniciusbit avatar Jul 18 '23 22:07 viniciusbit

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

ankitguheSS avatar Jul 19 '23 13:07 ankitguheSS

Has anyone come up with any solutions ?

nazad23 avatar Aug 14 '23 20:08 nazad23

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

arizmendiomar avatar Aug 16 '23 05:08 arizmendiomar

Same issue here!

joafeldmann avatar Aug 18 '23 14:08 joafeldmann

any update or fix on this issue?

maniejhunreyes avatar Aug 21 '23 07:08 maniejhunreyes

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

dkirchan avatar Sep 20 '23 10:09 dkirchan

Did anyone find solution or any workaround for this?

nischaytv avatar Dec 20 '23 04:12 nischaytv

I am also still searching for solution on this

ilija-scale avatar Dec 21 '23 15:12 ilija-scale

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.

ptakpatryk avatar Jan 22 '24 14:01 ptakpatryk