cypress-io / cypress

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

CT setup detection may fail if launchpad skipped (`--component` used to open) #27410

Open MikeMcC399 opened 1 year ago

MikeMcC399 commented 1 year ago

Current behavior

If Cypress is launched with

npx cypress open --component

after component testing dependencies have been installed and Cypress has not yet been set up for component testing then the dependencies may not always be detected.

(See Component Testing > Getting Started Open Cypress which specifically mentions --component as an option at this point.)

Using the CLI option --component by-passes the launchpad. If this option is omitted and Component Testing is selected manually in the launchpad, then the dependencies are correctly detected.

The issue affects some monorepo sub-directories.

Desired behavior

During Cypress component testing setup, when component testing dependencies have been installed, then dependencies should be reliably detected when Cypress is launched with

npx cypress open --component

Test code to reproduce

git clone --branch test/ct-detection https://github.com/MikeMcC399/github-action
cd github-action/examples/cy-react-vite-ct
npm ci
npx cypress open --component

Note that the Cypress app opens and requests a framework to be picked although a framework is already installed.

Pick a framework

Close the Cypress app and restart with

npx cypress open

Select "Component Testing" and note that now "React.js" and "Vite" are detected.

Confirm framework

Cypress Version

First reported on version: 12.17.2 Continues to be reproducible on version: 13.15.2

Node version

18.17.0 & v20.17.0

Operating System

Ubuntu 22.04.3 LTS (also reproducible on Windows 11)

Debug Logs

zipped to

Other

Workaround

Initialize git in the monorepo sub-directory to prevent Cypress traversing upwards in the git hierarchy:

cd github-action/examples/cy-react-vite-ct
git init
lmiller1990 commented 1 year ago

Maybe related: https://github.com/cypress-io/cypress/issues/22777

MikeMcC399 commented 1 year ago

@lmiller1990

Related:

The repo https://github.com/MikeMcC399/github-action reliably reproduces the issue (see original post), so hopefully you will be able to dig into this successfully.