TL;DR Don’t forget to “dotenv/config” for those jest tests that need to access process.env.

Just spent an hour wondering why a jest test is not picking up process.env variables.

It’s embarrassingly simple as you can see from this gist:

However I had forgotten the import “dotenv/config”.

I then realized…

--

--

Sebastian Rogers

Sebastian Rogers

Technical Director for Simple Innovations Ltd. First paid for code in 1980, but still has all his own hair.