'Load .env in globalTearDown JEST

.env variable are not visible during --globalTearDown function in JEST.

I'm currently loading them in the --setupFiles ( or in --setupFilesAfterEnv), but still when calling the teardown funciton they are not there, unless I reload them with dotenv.config().

I would like to know if it is fine to re-load them? and why this is happening?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source