cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.06k stars 3.19k forks source link

Specifying specPattern via CLI args doesn't work in component-testing mode #29317

Open YordanIliev2002 opened 7 months ago

YordanIliev2002 commented 7 months ago

Current behavior

Problem

We have two types of component tests, and we want to run them separately, while using the same cypress.config.ts. Ideally, one such run would look like:

# first type
yarn cypress run --component --config specPattern=['**/*.type-1.tsx']

However, such runs don't match any specs. (however, files like those exist)

Can't run because no spec files were found.

We searched for specs matching this glob pattern:
<valid glob that leads to the files that I want>

Workaround

Specifying the specPattern via the JSON --config works.

yarn cypress run --component --config '{ "component": {"specPattern":["**/*.type-1.tsx"]}}'

Assumption about what happens

We have used the "problematic" approach for splitting e2e tests. The problem happens only for component tests. My suspicion is that --config specPattern=['**/*.type-1.tsx'] overrides the property e2e.specPattern instead of component.specPattern, even when --component is used. And then the files get excluded, because of cypress' logic:

Screenshot 2024-04-12 at 12 32 46

Desired behavior

I would expect that when using --component, --config would override the component part of cypress.config.ts.

Test code to reproduce

Not working

yarn cypress run --component --config specPattern=['**/*.type-1.tsx']

Working

yarn cypress run --component --config '{ "component": {"specPattern":["**/*.type-1.tsx"]}}'

Cypress Version

13.7.2

Node version

v20.12.0

Operating System

macOs 14.4.1

Debug Logs

No response

Other

No response

cypress-app-bot commented 1 month ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

YordanIliev2002 commented 2 weeks ago

The behaivor is still occurring on Cypress 13.15.1