I was trying to use my environment variables in my test suites and it was a hustle. After a long time of trying and researching, I finally found a way to do it and I decided to write this article to help save you time, lol.
Funny how it's quite easy and I wonder why it took me so long to get it done. Well, we learn every day.
I'm using dotenv for the environment variables and jest for testing and all you need to do is add the dotenv config to the jest setup files in your package.json file. Yes, it's that easy
I hope with this short article I've been able to help you save time in configuring dotenv with jest, lol.