I have an app that depends on environmental variables like:
const APP_PORT = process.env.APP_PORT || 8080;
and I would like to test that fo
Expanding a bit on Serhan C.'s answer (https://stackoverflow.com/a/57944454/2708174)...
according to this blog https://tekloon.dev/using-dotenv-with-jest
you can include "dotenv/config" directly in setupFiles, without having to create and reference an external script that calls require("dotenv").config().
i.e., simply do
module.exports = {
setupFiles: ["dotenv/config"]
}