Closed hetsch closed 3 years ago
Hi @hetsch - thanks for pointing out that the plugin won't run when installed globally. I'll consider if the launcher needs to be improved. However, I wonder if there is a need to install it globally? As you have shown, there are issues in locating the module when it is installed globally. If you would install it locally instead, both the launcher would work and the command file would be found.
I haven't tried out the plugin in docker, so maybe there is some reason to install it globally in that environment? I looked at some issues related to plugins and docker, and it seems the recommendation is to add them to the local package.json and do npm install, which means they will be installed locally.
Hi @bjowes - the thing is, that cypress is installed globally in the Docker image, and installing cypress-ntlm-auth locally ends up in cypress-ntlm-auth not finding the globally installed cypress module. Another reason for globally installing your plugin is that one can create a custom Docker image where all the requirements are already built in (globally installed).
Understood. I see that I need to make the imports (require) agnostic to local or global installs, while preferring local. I can look into it, but you are also welcome to make a PR if you have a solution in mind already.
Thank you for working on this issue. Sure, i'll continue to play around until I find something useful. But I have little hope that I'm much of a help considering my experience with Nodejs.
As I understand it, you have two options:
1) Install cypress-ntlm-auth both globally and locally. That way, you launch it with the global version, which then uses the global cypress install correctly. The custom commands (from cypress/support/index.js
) are imported from the local install.
2) Install cypress-ntlm-auth globally and use a custom import path in cypress/support/index.js
. This may sound simpler, and it is as long as you don't need to have a portable environment. The custom import path will be different with different OS variants, and also if you have multiple Node installations. But if all that stays the same (which I figure it should in docker) this is quite useful.
So, what custom import path? You can find that out by executing npm root -g
in your container. Prefix the import statement of cypress-ntlm-auth with this path. The typical path for a linux installation should be /usr/local/lib/node_modules
, meaning that the import statement in cypress/support/index.js
should be
import "/usr/local/lib/node_modules/cypress-ntlm-auth/dist/commands";
Please try it out. I will prepare a patch for the launcher.
Hi @bjowes, I tried point 2 and it works. What I needed to add was t === "/usr/local/bin/cypress-ntlm"
as mentioned above. Thank you for the hints!
Hi,
thank you for your nice package! I wonder if you have ever tried to use your module with a Docker image like
cypress-io/cypress-docker-images
(https://github.com/cypress-io/cypress-docker-images/blob/master/included/5.3.0/Dockerfile) or similar. I cannot get it working, because cypress is installed in the container as a global package and installing cypress-ntlm-auth as a global dependency errors out with something like the below:Looking at these lines https://github.com/bjowes/cypress-ntlm-auth/blob/a5aff3ace7fee670dfe62726af622925702dce8a/src/startup/startup.ts#L47-L52 gives me the impression that cypress-ntlm-auth should or could only be used as a local dependency.
Changing these lines to accept the
/usr/local/bin
prefix, starts cypress without any error messages:Inside the project browser, clicking on a spec and opening the test in Electron provides me the following error message:
This seems to be related to Webpack not knowing anything about the cypress-ntlm-auth module. Any thoughts and ideas are more than welcome!