I am in the process of implementing an API for the OPTIONS request for a pre-flight check on CORS calls.
The Allowed-Origins host between local, test and prod will all be different so I moved this to a dotenv file.
Now though when I create my unit test to validate this there is an issue
Lets say that local has a value of localhost:3000 but test has test.site.com and prod is site.com
So now the test that verify headers
Will only pass in local.
A couple ideas I had and reason I think they would not cover the cases:
Hard code like above each env condition would leave failing test in other environment.
Load the env files and validate that but this is useless because I am confirming the file equals the file.
Load the env file for each env and hardcode the expectation in the assert. Could work the plan is not to have local or prod in test.