diff --git a/src/bin/cy-grep.js b/src/bin/cy-grep.js index 35b6b9d..7366b70 100644 --- a/src/bin/cy-grep.js +++ b/src/bin/cy-grep.js @@ -234,11 +234,18 @@ try { } } - console.log(`${packagename} Running tests === `); - let specPattern = getSpecPattern(fileSpecPatternOriginal); let specString = getSpecPatternVar(specPattern, grep, onlyRun); + if (process.env['CYPRESS_GREP_failOnNotFound'] === 'false' && specString === 'CYPRESS_SPEC_PATTERN="[]"') { + console.log(`${packagename} Not found any specs matching ${grepExpression}`); + console.log(`${packagename} To throw error when not found set CYPRESS_GREP_failOnNotFound to true`); + console.log(`${packagename} FINISHED (exit code: 0) === `); + process.exit(0); + } + + console.log(`${packagename} Running tests === `); + // to use from cypress config when not set const exclTests = showExcludedTests !== undefined ? `CYPRESS_GREP_showExcludedTests=${showExcludedTests === true}` : ''; diff --git a/src/setup/select-tests.ts b/src/setup/select-tests.ts index 8f5f5c9..7848259 100644 --- a/src/setup/select-tests.ts +++ b/src/setup/select-tests.ts @@ -219,7 +219,7 @@ export const setupSelectTests = ( `Not found any tests matching ${grepEnvVars.GREP} '${grep}' satisfying specPattern ${Cypress.env( 'originalSpecPattern', )}`, - `To disable this error set \`failOnNotFound\` to \`false\` in registerCypressGrep or set environment variable ${grepEnvVars.failOnNotFound} to false`, + `To disable this error set environment variable \`${grepEnvVars.failOnNotFound}\` to false or set \`failOnNotFound\` to \`false\` in registerCypressGrep`, ]; throw new Error(msg.join('\n')); }