You are checking the value of the environment variable a single time out in the global space when your app starts. But the tests work by changing the value of the environment variable when your app is running. You need to check the value of the environment variable inside of your GET handler so that your app can respond to changes in the environment variable.