Angular 5 "ng test" fails for application with BingMap

Viewed 203

I used a bing map loader for my angular 5 application to load the script.

used the following code

@Injectable()
export class MapLoaderService {

  private static promise;

  public static load() {
    if (!MapLoaderService.promise) {
      MapLoaderService.promise = new Promise(resolve => {
        window['__onBingLoaded'] = (env) => {
          resolve('Bing Map API loaded');
        };

        const node = document.createElement('script');
        node.src = url;
        node.type = 'text/javascript';
        node.async = true;
        node.defer = true;
        document.getElementsByTagName('head')[0].appendChild(node);
      });

      return MapLoaderService.promise;
    }
  }

  constructor() { }
}

the application works fine with this loader service. But after writing unit tests and when running "ng test", It is showing the following error

ERROR in src/app/bing-map/bing-map.component.ts(25,21): error TS2304: Cannot find name 'Microsoft'.

How can i load the bing map script for unit test ?

0 Answers
Related