bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
55 stars 10 forks source link

The plug in silently stops executing when opening with the parameter --config baseUrl #83

Closed luis-m-gonzalez closed 4 years ago

luis-m-gonzalez commented 4 years ago

I tested this and could reproduce on Cypress 3.50 and 3.60

I have multiple npm scripts to run Cypress with NTLM, some including options. These Scripts execute without problem:

"scripts": { "ntlm-proxy": "start /min \"ntlm-proxy\" cmd /c node_modules\.bin\ntlm-proxy", "cy": "npm run ntlm-proxy && (cypress-ntlm open & ntlm-proxy-exit)", "cyr": "npm run ntlm-proxy && (cypress-ntlm run & ntlm-proxy-exit)", "cyrc": "npm run ntlm-proxy && (cypress-ntlm run --browser chrome & ntlm-proxy-exit)", "cyrf": "npm run ntlm-proxy && (cypress-ntlm run --spec 'cypress/integration/PlanHeaderEditLinkedPlans.feature' & ntlm-proxy-exit)" }

However if instead I try to set the baseUrl like this: "cyci": "npm run ntlm-proxy && (cypress-ntlm run --config baseUrl=http://localhost/ui & ntlm-proxy-exit)"

The proxy and cypress don't start, and also no error is sent to the output. The execution just stops silently.

Thanks for your help!

bjowes commented 4 years ago

That is odd. I tried it out on my Mac and it seems to work fine with overriding baseUrl - the script syntax is slightly different but quite similar. Will try it out on Windows tomorrow. I guess you already tried running the commands separately (starting up ntlm-proxy in one cmd window and running cypress-ntlm run ... in another)? If that works, there must be some collision with the script syntax on windows.

bjowes commented 4 years ago

Ah, I think I found it. Windows actually treats equal signs as a separator for arguments, so I think it will disappear before cypress is launched. There are two ways around it - either you escape the equal sign with ^= or you put the whole argument in quotes (I would go with the second way). Your command would then turn into "cyci": "npm run ntlm-proxy && (cypress-ntlm run --config \"baseUrl=http://localhost/ui\" & ntlm-proxy-exit)"

luis-m-gonzalez commented 4 years ago

Thanks @bjowes . I think you are correct, in that illegal characters have something to do with the problem. However I tried both solution #1, #2 and it doesn't fix the problem. I tried both of them together and still no luck. I'll keep trying alternatives

luis-m-gonzalez commented 4 years ago

I can tell that the issue is with the '//' rather than the equals, but I haven't found a way to escape this.

These won't work: cypress-ntlm run --config "baseUrl=http://localhost/ui" cypress-ntlm run --config baseUrl="http://localhost/ui"

This one will: cypress-ntlm run --config baseUrl=http:/localhost/ui

But of course, that is not a valid URL

luis-m-gonzalez commented 4 years ago

This combination works npm run ntlm-proxy && node_modules\.bin\cypress-ntlm run "baseUrl=http://localhost/ui"

bjowes commented 4 years ago

Well, I have now tried this out on Mac and Windows. Your original command works without any escaping or quotes - but only with Cypress 3.3.2.

Apparently this is already a recognized issue from Cypress 3.5.0 and Cypress 3.6.0. The only workaround posted suggests using environment variables instead.

Since this is a pure Cypress issue there is not much I can do from my side. I'll close this and recommend that you follow the Cypress issues.

luis-m-gonzalez commented 4 years ago

thanks!