Closed nknysh closed 4 years ago
Hi @nknysh - it seems the env command in npm doesn't work that well on windows. You should be able to get it working using:
"scripts": {
"ntlm-proxy": "start /min \"ntlm-proxy\" cmd /c node_modules\\.bin\\ntlm-proxy",
"cypress-ntlm": "set NODE_TLS_REJECT_UNAUTHORIZED=0 && npm run ntlm-proxy && (cypress-ntlm open & ntlm-proxy-exit)"
}
Thanks @bjowes!
This is one of the things I tried. But then, in Cypress, process.env
does NOT contain this variable.
Can it be not set in Cypress, but already set for ntlm-proxy, which is ran right after the set
command?
It's actually not needed by cypress itself, only by ntlm-proxy since cypress already ignores cert errors. There is no easy way to see if it is set for ntlm-proxy though, but I guess you can just try it?
You can compare the results if you manually do set NODE_TLS_REJECT_UNAUTHORIZED=0
in the command prompt before you do npm run cypress-ntlm
, this will set it for sure for both cypress and ntlm-proxy.
@bjowes you're right - I use Windows (and powershell). It didn't work for me from within package.json, but I succeeded with this powershell script:
$scriptBlock = {
$Env:NODE_TLS_REJECT_UNAUTHORIZED='0'
npm run cypress-ntlm
}
Invoke-Command -ScriptBlock $scriptBlock
Thanks for your help, and for the awesome plugin you give to the world! :)
I'm glad it worked out and that you enjoy the plugin :) I have noticed that I frequently receive questions similar to this one. Setting environment variables in Windows from package.json seems a bit tricky, what works for some doesn't work for others. I'll consider adding something about this to the docs.
On windows, got environment variable to work with no space between &&
"ntlm-proxy": "set NODE_TLS_REJECT_UNAUTHORIZED=0&&start /min \"ntlm-proxy\" cmd /c node_modules\\.bin\\ntlm-proxy",
I try to use the way close to what is recommended in readme:
"scripts": { "ntlm-proxy": "start /min \"ntlm-proxy\" cmd /c node_modules\\.bin\\ntlm-proxy", "cypress-ntlm": "npm run-script env NODE_TLS_REJECT_UNAUTHORIZED='0' ntlm-proxy && (cypress-ntlm open & ntlm-proxy-exit)" }
Then, when I run with
npm run cypress-ntlm
, I get an error sayingReadme says
Can you please example how I should pass the env variable to ntlm-proxy? And sorry if the question is stupid - I'm new to node/npm.
Thanks!