Skip to content

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

Open
@yonasberhe23

Description

@yonasberhe23

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions