Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
How do I inject GooglePlaceModule into Jasmine unit test

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!