Question, I've a situation where I filter with a RegExp the Cypress tests, in the Cypress plugins folder.
This check is done on a javascript level with a custom lib that check with git diff the updated files of the branch I am in, during the execution of Cypress tests.
This functionality works properly both locally and within a Jenkins pipeline.
There are some cases where this RegExp filters all tests out, meaning: there is no need to run any Cypress tests (what it means is that it was touched some code that is not affecting anything regarding components of a UI library, so any Cypress tests is necessary).
Is there a way to prevent in this case, the failure of Cypress suite?
I would love that my package.json script that run Cypress tests is executed but without failure of the command if zero tests are found.
$ cypress run --headless
[ '**/time.**' ]
Can't run because no spec files were found.
We searched for any files inside of this folder:
cypress/integration/functional
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! .......
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ....... test:cy:run:functional script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! .npm/_logs/2021-08-20T06_41_30_883Z-debug.log
Error: Command failed with exit code 1: npm run test:cy:run:functional
{
command: 'npm run test:cy:run:functional',
exitCode: 1,
signal: undefined,
signalDescription: undefined,
stdout: undefined,
stderr: undefined,
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
Thanks in advance