I want to test the behavior of my app by pushing it to the staging app on Heroku. There's a part that saves information to s3 that I want the app to execute when in production, but to skip over while testing it in staging. Is there a way to do this? I've been manually commenting it in and out but it'd be nice if it could automatically do it. I'm using node and express if that helps.
You can feature base your code
. Just add an environment variable and check the value of that variable on your code. If the value is true
execute the code, if not, then don't. We do those things all the time on different environments when we release new features to reduce the possible impact.
{
"name": "my app",
"description": "My super app",
"scripts": {},
"env": {
"MY_ENV_VAR": {
"required": true
}
}
3.Check the value of the variable on your code:
if (process.env.MY_ENV_VAR === 'true') { //keep in mind these will be strings
//do your logic
}
Regards