In our angular app, we use environment files to load some config.
environment.ts
export const environment = {
production: false,
defaultLocale: \'en
A technique I use in situations like this is to create a wrapper service e.g. EnvironmentService.ts
and in this case it returns the environment configuration.
This allows me to mock calls to the EnvironmentService
's getEnvironmentConfiguration
method just like any other spyOn
call.
This then allows for the modification of environment variables in unit tests :)