I'm trying to write a unit test for a component that uses the GooglePlaceModule. I keep getting a failed test with the following error:
Failed: Google maps library can not be found
I've tried 2 things online while searching for resolutions:
I added this line in the karma.conf.js file per the suggestion:
files: [
'https://maps.googleapis.com/maps/api/js?key=<key>=places&language=enhttps://maps.google.com/maps/api/js?key=<removed>&libraries=places'
],
That didn't work.
Here's my spec file:
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ProfileFormComponent } from './profile-form.component';
import { ReactiveFormsModule } from '@angular/forms';
import { GooglePlaceModule } from 'ngx-google-places-autocomplete';
describe('ProfileFormComponent', () => {
let component: ProfileFormComponent;
let fixture: ComponentFixture<ProfileFormComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ProfileFormComponent ],
imports: [IonicModule.forRoot(), ReactiveFormsModule, GooglePlaceModule]
}).compileComponents();
window['google'] = {
maps: {
Maps: () => {}
}
};
fixture = TestBed.createComponent(ProfileFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
It's pretty basic so far, I'm just trying to get the minimal to pass.