Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

254
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda