angularunit-testingkarma-jasmineangular11

Angular Unit - Testing (Jasmin Karma) : Error :Cannot find name 'google'


google.directives.ts:-

  getAutocompletes(addresstext: ElementRef) {
    const autocomplete = new  google.maps.places.Autocomplete(addresstext.nativeElement,
      {
       ...
      });
  google.maps.event.addListener(autocomplete, 'place_changed', () => 
  {
   ...
  }

after testing code in jasmin & karma, I got Error :-> Cannot find name 'google'.

How can I solve this issue for unit testing? I alreday added "googlemaps" in tsconfig.app.json.


Solution

  • Whatever change you made for tsconfig.app.json for it to work, you have to do the same change to tsconfig.spec.json for the unit tests to work.