# Mocking Environment Variables

Sometimes, your app might behave differently depending on an ENV variable's value or presence/absence.

Ideally, you'd want the values of a few important ENV vars to be the same across RECORD and REPLAY modes. You can achieve this by telling the hypertest sdk what these important ENV vars are.

Hypertest will monitor the important ENV vars in RECORD mode, and mock this value u REPLAY MODE transparently for you.

Monitoring only works in server contexts (inside an http/grpc/amqp etc request) and not for root contexts

&#x20;This is how you tell hypertest to monitior specific env vars\ <br>

```typescript
import * as htSdk from '@hypertestco/node-sdk';
htSdk.setImportantEnvVariables(['SAMPLE_ENV_VAR', 'ANOTHER_IMPORTANT_ENV_NAME']);
```

```javascript
/* sample usage in rest of app code */
app.get('/my_url', (req, res) => {
 // unrelated code
  if(process.env.SAMPLE_ENV_VAR === 'some_value') {
     console.log('do something')
  } else {
     console.log('do something else')
  }
  
  // unrelated code
  
});

```

You can only set important env variables once, so do this after the SDK has been initialized at the start of your application


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-v2.hypertest.co/user-guides/node.js-sdk/mocking-environment-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
