Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Karma/Jasmine testing Ionic 6 - NullInjectorError: No provider for Geolocation

$
0
0

Hello,

I am receiving the following error when attempting to test with Ionic Native Geolocation as a dependency:

Failed: R3InjectorError(DynamicTestModule)[Geolocation -> Geolocation]:
          NullInjectorError: No provider for Geolocation!
        error properties: Object({ ngTempTokenPath: null, ngTokenPath: [ 'Geolocation', 'Geolocation' ] })
        NullInjectorError: R3InjectorError(DynamicTestModule)[Geolocation -> Geolocation]:
          NullInjectorError: No provider for Geolocation!

Here is what the test set up looks like:

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule, IonItem, Platform } from '@ionic/angular';
import { FoloLocation } from '../models/folo-location';
import { Geolocation } from '@ionic-native/geolocation/ngx';
import { HomePage } from './home.page';

describe('HomePage', () => {
  let component: HomePage;
  let fixture: ComponentFixture<HomePage>;
  let platform: Platform;

  beforeEach(waitForAsync(() => {
    TestBed.configureTestingModule({
      declarations: [ HomePage ],
      imports: [IonicModule.forRoot()],
      providers: [
        Geolocation
      ]
    }).compileComponents();

    fixture = TestBed.createComponent(HomePage);
    component = fixture.componentInstance;
    platform = TestBed.inject(Platform);
    fixture.detectChanges();
  }));

I have also tried providing a mock, to no avail.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>