cypress-io / cypress

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

A way to finish running zero specs without exit code 1 #25508

Open bahmutov opened 1 year ago

bahmutov commented 1 year ago

What would you like?

Let's say I have a plugin like cypress-split or cy-grep that changes the list of specs to run. Sometimes there might be no specs to run at all. It would be nice if the plugin could so something like this and Cypress would exit with code zero

setupNodeEvents(on, config) {
  config.specPattern = []
  config.expectZeroSpecs = 0
  return config
}

Currently, if you set an empty spec list, then it exits with 1

Can't run because no spec files were found.

We searched for specs matching this glob pattern:

Why is this needed?

Expecting no specs might be useful. It will be useful for my plugins for sure

Other

No response

nogwater commented 1 year ago

My team is having this problem with the built-in @cypress/grep package and the grepTags environment variable combined with the --spec option. Here's an example run showing this issue:

$ npm run cy:run-report -- --spec='./cypress/e2e/poc/**/*.cy.*' --env testEnv='latest',grepTags='@regression'

> cypress@1.0.0 cy:run-report
> cypress run --browser chrome --reporter junit --reporter-options "mochaFile=cypress/results/Test-[hash].xml,toConsole=true" --spec=./cypress/e2e/poc/**/*.cy.* --env testEnv=latest,grepTags=@regression

DevTools listening on ws://127.0.0.1:61839/devtools/browser/d59a1760-3a01-4c9d-8e95-46e282048d67
@cypress/grep: filtering using tag(s) "@regression"
@cypress/grep: will omit filtered tests
Couldn't determine Mocha version
Can't run because no spec files were found.

We searched for specs matching this glob pattern:

  > C:\Git\cypress\cypress\e2e\poc\**\*.cy.*
istateside commented 1 year ago

Sounds like this issue is asking for the same feature as https://github.com/cypress-io/cypress/issues/23019

+1 on needing this, my team just got bit by it today. We filter our tests down based on a network request to an external service that we use to temporarily "quarantine" tests that start failing unexpectedly - i.e. the test is dependent on some live service that we didn't anticipate, or we have a test that seems stable when it's added, but then starts failing 2% of the time when run on CI many times a day. One of our small applications only has two Cypress tests, and we ended up needing to quarantine both of them yesterday - now the build is failing, because Cypress isn't finding any valid spec files to run.