0

I have created a class in Angular 7 to load a config file for environment variables. This is using the accepted answer here Angular5: Deploying Angular application to multiple clients

Now I want to add unit testing to my Services but I get the following error:

TypeError: Cannot read property 'apiURL' of undefined

In other words when appConfig is imported, it is not recognised.

How can I stub the variable below to solve the error? I've tried using spy's but cannot get it working:

/**
 * Global variable containing actual config to use. Initialised via ajax call
 */
export let appConfig: AppConfig;
Christopher Grigg
  • 2,238
  • 27
  • 33

0 Answers0