Skip to content

Commit

Permalink
[patch] fix fail on not found (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmisty authored Jan 9, 2024
1 parent 4a067d6 commit 88367df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/bin/cy-grep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}` : '';
Expand Down
2 changes: 1 addition & 1 deletion src/setup/select-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down

0 comments on commit 88367df

Please sign in to comment.