# Environment variables for local server and testing (Jest)

**URL:** <https://community.parseplatform.org/t/environment-variables-for-local-server-and-testing-jest/2660>\
**Category:** Cloud Code\
**Tags:** testing\
**Created:** [May 10, 2022, 12:34pm UTC](https://community.parseplatform.org/t/environment-variables-for-local-server-and-testing-jest/2660 "2022-05-10T12:34:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![claesjacobsson](https://community.parseplatform.org/letter_avatar_proxy/v4/letter/c/2bfe46/32.png) [@claesjacobsson](https://community.parseplatform.org/u/claesjacobsson)\
**Post date:** [May 10, 2022, 12:34pm UTC](https://community.parseplatform.org/t/environment-variables-for-local-server-and-testing-jest/2660/1 "2022-05-10T12:34:34Z")

</div>

Not super confident in JS/Node, so need some clarification regarding environment variables.

My app is running on Sashido, where I can configure Environment Variables in their dashboard. For running my server locally while developing, I’ve been using an `.env` file. Now, I’ve added testing with Jest and to add ENV in the tests I import a `setEnvVars.js` file in the `jest.config.js` file.

Can you recommend a way to provide the env vars for running locally and testing (JEST) in a single solution? I now rely on both the `.env` file and `setEnvVars.js`, which basically contain duplicate info.

My `jest.config.js`

```auto
module.exports = {
  setupFiles: ["./setEnvVars.js"]
};

```

---

<div class="post-metadata">

**Author:** ![davimacedo](https://community.parseplatform.org/user_avatar/community.parseplatform.org/davimacedo/32/316_2.png) [@davimacedo](https://community.parseplatform.org/u/davimacedo)\
**Post date:** [May 10, 2022, 4:11pm UTC](https://community.parseplatform.org/t/environment-variables-for-local-server-and-testing-jest/2660/2 "2022-05-10T16:11:39Z")

</div>

Given your current setup, the easiest way is to just replace the current content of your `setEnvVars.js` to:

```auto
require('dotenv').config()

```

It will load the env vars from your existing `.env` file.

---

<div class="post-metadata">

**Author:** ![claesjacobsson](https://community.parseplatform.org/letter_avatar_proxy/v4/letter/c/2bfe46/32.png) [@claesjacobsson](https://community.parseplatform.org/u/claesjacobsson)\
**Post date:** [May 10, 2022, 4:52pm UTC](https://community.parseplatform.org/t/environment-variables-for-local-server-and-testing-jest/2660/3 "2022-05-10T16:52:38Z")

</div>

That seems pretty obvious and straightforward once in front of me 🙂 Thanks a lot!
