Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Errors and Performance Inefficiencies When All Tests Are Filtered Out in Cypress #31024

Open
yonasberhe23 opened this issue Feb 5, 2025 · 1 comment
Labels
npm: @cypress/grep @cypress/grep package issues type: performance 🏃‍♀️ Performance related

Comments

@yonasberhe23
Copy link

yonasberhe23 commented Feb 5, 2025

What would you like?

Description:
When using the @cypress/grep plugin to filter out tests based on tags, if no tests match the filter or all tests are excluded, Cypress still loads all spec files before applying the filter. This leads to unnecessary resource usage and potential uncaught errors during the setup phase (such as issues with base64 decoding or JSON parsing), even though no tests are executed.

Current Behavior:
Even when all tests are filtered out, Cypress still loads all spec files and executes the setup code, which can result in uncaught errors (e.g., JSON parsing or decoding failures). These errors cause the entire test suite to fail. Additionally, this behavior is inefficient, as it wastes system resources by loading and processing spec files that ultimately won’t be run.

Ideal Behavior:
If no tests match the filter criteria or if all tests are excluded, Cypress should skip loading the spec files entirely or, at the very least, avoid executing any setup code. This would prevent errors from impacting the test run and eliminate unnecessary resource consumption.

Please refer to this example code.
To repro the issue run yarn test to execute the script within package.json

@jennifer-shehane jennifer-shehane added type: performance 🏃‍♀️ Performance related npm: @cypress/grep @cypress/grep package issues labels Feb 5, 2025
@jennifer-shehane
Copy link
Member

@yonasberhe23 We have to read the files to see the test definitions themselves. If there's a syntax error in the test file, I'm not sure we could do much with that. We have to read the files to see whether there are tests that need to run or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm: @cypress/grep @cypress/grep package issues type: performance 🏃‍♀️ Performance related
Projects
None yet
Development

No branches or pull requests

2 participants