Jest test not reading environment variables with dotenv
问题 I'm running a test on a function that calls for environment variables, I'm getting undefined. Solutions I tried and didn't work: 1/ add require('dotenv').config({path:'../.env'}) in my test file 2/ pass globals in package.json "jest": { "globals": { "USER_ENDPOINT":"xxx", "USER_KEY":"xxx" } } 3/ pass my variables in test command in package.json "test": "USER_ENDPOINT:xxx USER_KEY:xxx jest --watchAll --detectOpenHandles" 4/ added an Object.assign in a beforeEach() in my test file beforeEach(()