Open willydee opened 2 years ago
@willydee, could you somehow share a sample project to reproduce the issue? it's not a big deal to add an option to modify the $PATH but I need a sample to verify your problem is fixed.
if it's not possible, I can provide you a (not tested) plugin snapshot with the option added and you can check it in your environment.
I think that's the faster way, since I'm not so familiar yet with setting up a complex project like the one used by our team. I'll happily test a snapshot.
here is a snapshot: Cypress Support Pro-2.5.2-SNAPSHOT.zip
Mike, the plugin successfully installed after downgrading Webstorm form 213.x to 212.x. cypress
is correctly found in node_modules/.bin
.
Still I have troubles getting tests to launch; looks like an assumption is made that everything is located relative to the project root; all paths are expanded from there. Our Cypress project is located in a subfolder <PROJECT_ROOT>/apps/control-panel-cy
, which I correctly entered into the Cypress project base
field. The file cypress.json
is assumed to be in the project root:
$ /home/willy/Projects/control-panel/node_modules/.bin/cypress run -b chrome --headed --reporter /tmp/intellij-cypress-reporter11003797996885613353.js --spec /home/willy/Projects/control-panel/apps/control-panel-cy/src/integration/...
Could not find a Cypress configuration file, exiting.
We looked but did not find a cypress.json file in this folder: /home/willy/Projects/control-panel
If I specify the full path in the Program arguments
, the config file is found, but again, all paths are expanded relative to the project root instead of the specified Cypress project base:
$ /home/willy/Projects/control-panel/node_modules/.bin/cypress run -b chrome --headed --config-file apps/control-panel-cy/cypress.json --reporter /tmp/intellij-cypress-reporter11003797996885613353.js --spec /home/willy/Projects/control-panel/apps/control-panel-cy/src/integration/...
The support file is missing or invalid.
Your `supportFile` is set to `/home/willy/Projects/control-panel/src/support/index.ts`, but either the file is missing or it's invalid.
Relevant entry in cypress.json
:
"supportFile": "./src/support/index.ts"
Maybe I'm just missing or misunderstanding a config option...
My last run configuration (project root is /home/willy/Projects/control-panel
):
It's a bit hard for me to calculate all the paths without a sample directory structure.. Anyway, how do you run the tests from command line?
That's what our project structure basically looks like (the relevant parts):
<PROJECT_ROOT>/
apps/
control-panel/ # the Angular application source tree
control-panel-cy/ # the Cypress end-to-end tests (supposedly `Cypress project base`)
src/
integration/ # contains the `Test files` grouped in subdirectories
pages/
plugins/
support/
cypress.json
node_modules/
.bin/
cypress # the Cypress executable
angular.json
packages.json
...
To run Cypress from command line, we do (assuming node_modules/.bin
is part of $PATH
):
$ cd <PROJECT_ROOT>/apps/control-panel-cy
$ cypress open
Hope this is of help to you.
Hmm, I've recreated your project structure.
But I'm unable to reproduce the problem, probably because I'm on Windows.
Could you also share the Runner
tab of your run configuration?
Sure.
For completeness (although not involved), the package.json
commands we're using to launch Cypress outside the IDE environment:
"e2e:cypress:open": "cypress open --project apps/control-panel-cy --browser chrome",
"e2e:cypress": "cypress run --project apps/control-panel-cy --browser chrome",
"e2e:cypress:ci": "cy2 run --record --key notNecessaryWithSC --project apps/control-panel-cy --browser chrome --parallel",
hey @willydee,
could you try to add --project apps/control-panel-cy
to you run configuration and check if it helps?
Also, it seems you should set the cypress project base to this:
Er, I know this is over a year old. But for what it's worth I had exactly the same problem and your last suggestion @mbolotov to add the program argument --project <path-to-cypress-workspace>
works. It does not seem to matter what the Cypress project base
is set to. This was confusing for me.
I would expect the Cypress project base
to works since it seems specifically intended for that (and program arguments is just for random other options not supported directly by the plugin UI presumably). Also when clicking on the "play" icon in a test to automatically create a run configuration, the Cypress project base
gets correctly auto-filled, so it would be nice if the configuration worked without any further tweaking.
I'm just happy I have an option to run Cypress tests in an integrated way in the IDE.
Hi James,
Could you share a sample project to reproduce the problem?
Sure, here: https://github.com/jancellor/cypress-test-yarn
I struggled to reproduce at first but I think the key thing is if it is yarn 1 project. I tried first with npm 9 and the config file is found fine.
In the run window I either see a single line for npm:
/home/.../.nvm/versions/node/v16.19.1/bin/npx cypress run --e2e ...
which works fine or multiple lines for yarn:
/home/.../.nvm/versions/node/v16.19.1/bin/yarn run cypress run
yarn run v1.22.19
$ /home/.../dev/cypress-test-yarn/node_modules/.bin/cypress run
Could not find a Cypress configuration file in this folder: /home/.../dev/cypress-test-yarn
@jancellor how to reproduce the problem using the cypress-test-yarn repo? it seems it has no any cypress stuff.
Apologies must have forgotten to commit (on a different machine now). Repository is updated. Open the project in the IDE, do a yarn install, open the file packages/app-e2e/src/e2e/app.cy.ts
, click on the play sign, choose Run > cy option.
FWIW, most if not all of these could be fixed (I think) by allowing customisation of the command used to invoke Cypress. For example, I use npx nx cypress-run {project}
in our monorepo. yarn run cypress open
won't work for us.
Steps to reproduce
Expected result
Cypress should be launched
What happens instead?
Console output
System info
Application versions
Path to Cypress executable
Additional info
Our project structure is perhaps not the usual setup, due to requirements of the CI. Cypress itself is installed in the
node_modules
of project root; the binary is correctly located innode_modules/bin
. But it is not found because that directory is not part of the user's$PATH
, and in Wayland it is notoriously hard to get any additional directory into the session path. Using Node Version Manager triggers similar troubles, so I had to completely ditch it a while ago.WebStorm itself has a setting for its integrated terminal:
☑ Add 'node_modules/.bin' from the project root to $PATH
, so that cypress can be run seamlessly from the built-in terminal. I have no idea why such an option is not generally available in Run/Debug Configurations; IMHO it would be very useful. But maybe a checkbox like that can be integrated into the plugin's configuration?