Cypress: 'cypress open' after global install should default to current directory

Created on 24 May 2019  路  3Comments  路  Source: cypress-io/cypress

Current behavior:

After installing cypress globally with npm install -g cypress and then starting it up with cypress open, the dialog requests that I select the project folder to use, despite the fact that the directory where the cypress open command was issued contains the project I want to test.

Desired behavior:

Even when installed globally, cypress should check the current working directory for a project and use that automatically if one exists.
I can work around this by using cypress open -P . but I think opening current working directory without specifying it would be more user friendly.

Versions

Tested on Cypress 3.3.1, Windows 10, Chrome 74

Most helpful comment

I understand your view @jennifer-shehane , but I think I didn't make myself clear. My expectation is that cypress open tries to use the current directory where you execute it - it does not matter which directory you did the global install from. In this way, the behavior of cypress open would be identical in local install and global install. I've noticed that cypress run already works this way, it uses the current directory both in local and global installs.

And a question on local/global - are there any known limitations/issues when using global install? I see hints here and there that local is recommended, but I haven't seen any statements regarding limitations. Local install is fine during development, I just think it can be quite beneficial to use global install for our CI machines. Less to install means shorter CI runtime, and our network environment where our CI machines are located is a bit dodgy so npm install cypress often fails.

All 3 comments

The global cypress is intended to just try out cypress and launch several projects if wanted. So, the intended use is to decide which projects to add after install. Pulling in the directory that you happened to globally install under would cause more confusion for those that aren't expecting this automatic read of their directories. The opt-in to choose which project is best.

We do recommend you install cypress per project as npm install cypress --save-dev though, as this will give you the most optimal experience.

I understand your view @jennifer-shehane , but I think I didn't make myself clear. My expectation is that cypress open tries to use the current directory where you execute it - it does not matter which directory you did the global install from. In this way, the behavior of cypress open would be identical in local install and global install. I've noticed that cypress run already works this way, it uses the current directory both in local and global installs.

And a question on local/global - are there any known limitations/issues when using global install? I see hints here and there that local is recommended, but I haven't seen any statements regarding limitations. Local install is fine during development, I just think it can be quite beneficial to use global install for our CI machines. Less to install means shorter CI runtime, and our network environment where our CI machines are located is a bit dodgy so npm install cypress often fails.

Cypress is huge and installing it in CI for every test run takes ages.

It's easier to use the Cypress docker image, where Cypress is already installed globally, and run the tests there. Docker will cache the image and every new test run is executed in a container, which is much quicker than installing Cypress every time.

However, with that setup installing Cypress locally in the project no longer make sense. In order to run tests in the project I would either use docker or install Cypress globally, then run the tests from the local folder.

In addition the current behaviour is inconsistent between "run" and "open", i.e. globally installed cypress will execute tests in the current folder with "cypress run" but not with "cypress open"....

Was this page helpful?
0 / 5 - 0 ratings