-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting NODE_TLS_REJECT_UNAUTHORIZED=0 doesn't work in jest@22+ #8449
Comments
Hi, is there any update on this regression? This might block users from updating past Jest v21 |
This is a blocker for us. We're trying not to have a flag in our services to turn off SSL. For testing, we have to use self-signed certs. Pretty much a dealbreaker :-( |
I tried to require server after setting environment variable in commit trivikr/jest-self-signed-certificate@864ef96 (under the assumption that update in process.env variables apply only for subsequent require statement) The issue still exists |
Any update on this regression? |
Having the same issue. |
Hi team, any suggestion on how to work around the regression to write the unit test? |
After some experimenting/debugging, I tbh still have no idea why Node doesn't pick up the setting or which change in v22 could have introduced this. As a workaround it seems that it works if you launch Jest with the env var set to 0 straight away. If it's just a few tests that need this, could also consider doing a separate Jest run for those if you don't want to set it for all tests. |
It looks like it doesn't pick up any change to |
Any update on this request? |
for me |
any update on this issue ? |
After researching this problem, it appears that jest wraps the env object with a proxy. Hence, any change on I ended up solving the problem by a monkey patching technique which enforces node trusting the self-signed root CA via syswide-cas. i.e. import { addCAs } from 'syswide-cas';
addCAs('path/to/rootCA.crt'); |
Any updates? |
Hi , Note I am able tto run same test using Jasmine with setting I have opened this issue please check. If any suggestions to resolve it. |
|
Doing the same in a setup file also seems to have no effect:
module.exports = {
setupFiles: "./setup.js",
};
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; |
Hey I found a workaround for this in jest 26 (if you are using jsdom). You are going to have to create a custom environment to run jest in which extends jsdom. With the upgrade to jsdom 16, jest is not aware of the "resources" option on the JSDOM constructor, this and a combination of a regression somewhere with process.env which some of this thread has picked up on doesnt allow NODE_TLS_REJECT_UNAUTHORIZED=0 to work anymore. Steps to patch:
|
Duplicate of #5118 |
Same as #9264 (comment). If you really need to test this flag, I suggest doing what was suggested in #8449 (comment) (a separate run). You should be able to set this in a Note that if nodejs/node#31852 is every implemented, it might be possible we do something about this |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
💥 Regression Report
A clear and concise description of what the regression is.
Last working version
Worked up to version: [email protected]
Stopped working in version: [email protected]
To Reproduce
Steps to reproduce the behavior:
cd jest-self-signed-certificate
jest-21
branch by runninggit checkout jest-21
npm test
is successfulmaster
branch by runninggit checkout master
npm test
failsExpected behavior
I expected test to succeed, it fails with:
Link to repl or repo (highly encouraged)
https:/trivikr/jest-self-signed-certificate
Run
npx envinfo --preset jest
Paste the results here:
Ref: aws/aws-sdk-js-v3#244
The text was updated successfully, but these errors were encountered: