How to mock environment files import in unit tests : <p>In our angular app, we use environment files to load some config. </p>

<p>environment.ts</p>

<pre><code>export const environment = {
  production: false,
  defaultLocale: 'en_US',
};
</code></pre>

<p>We then use it in one of our service:</p>

<pre><code>import { environment } from '../../environments/environment';
import { TranslateService } from './translate.service';

@Injectable()
export class LocaleService {
  constructor(private translateService: TranslateService){}

  useDefaultLocaleAsLang(): void {
    const defaultLocale = environment.defaultLocale;
    this.translateService.setUsedLang(defaultLocale);
  }
}
</code></pre>

<p>So I use the values in environment file in a service method.</p>

<p>In our test file, we can of course Spy on the translateService:</p>

<p><code>translateService = jasmine.createSpyObj('translateService', ['setUsedLang']);</code></p>

<p>But I don't know how to mock the environment values in my testing file (in a <code>beforeEach</code> for example). Or even transform it, for testing purpose, to a <code>Subject</code> so I can change it and test different behaviors.</p>

<p>More generally speaking, how can you mock such imports values in tests to be sure not to use real values? </p>
