Setting NODE_TLS_REJECT_UNAUTHORIZED=0 doesn't work in jest@22+
See original GitHub issue💥 Regression Report
A clear and concise description of what the regression is.
Last working version
Worked up to version: jest@21.2.1 Stopped working in version: jest@22.0.0
To Reproduce
Steps to reproduce the behavior:
- Clone repo https://github.com/trivikr/jest-self-signed-certificate
cd jest-self-signed-certificate- Change to
jest-21branch by runninggit checkout jest-21 npm testis successful- Change to
masterbranch by runninggit checkout master npm testfails
Expected behavior
I expected test to succeed, it fails with:
FAIL src/__tests__/server.test.js
server
✕ server sends response (38ms)
● server › server sends response
self signed certificate
Link to repl or repo (highly encouraged)
https://github.com/trivikr/jest-self-signed-certificate
Run npx envinfo --preset jest
Paste the results here:
npx: installed 1 in 1.231s
System:
OS: macOS High Sierra 10.13.6
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Binaries:
Node: 12.1.0 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
npmPackages:
jest: ^24.8.0 => 24.8.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:30
- Comments:21 (7 by maintainers)
Top Results From Across the Web
node_tls_reject_unauthorized=0 not working - You.com
Node says this warning when I run it: Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests ...
Read more >node.js - (node:26972) Warning: Setting the ... - Stack Overflow
(node:26972) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure ...
Read more >How to Resolve Certificate Errors in a NodeJS App with SSL ...
A practical guide to resolving SSL certificate errors. If you've worked on Node/Express App, you may already know that setting up the app...
Read more >Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED ...
Having it set to 0 means that node.js is not verifying that the SSL/TLS certificates have a proper and unbroken path up to...
Read more >HTTPS | Node.js v19.3.0 Documentation
HTTPS is the HTTP protocol over TLS/SSL. ... options <Object> Set of configurable options to set on the agent. ... Use 0 to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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:
Any update on this request?