lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 137 forks source link

No provider for GestureController! #180

Closed Uriel96 closed 7 years ago

Uriel96 commented 7 years ago

I followed the steps for unit testing ionic 2 applications you gave in http://lathonez.github.io/2016/ionic-2-unit-testing/ and its giving the following error: captura de pantalla 67

lathonez commented 7 years ago

I'm AFK at the moment. Someone else has raised the exact same issue in the past if you search closed issues you should find it.

On 24 Nov 2016 06:11, "Uriel96" notifications@github.com wrote:

I followed the steps for unit testing ionic 2 applications you gave in http://lathonez.github.io/2016/ionic-2-unit-testing/ and its giving the following error: [image: captura de pantalla 67] https://cloud.githubusercontent.com/assets/6753760/20575304/56cc5cfe-b17e-11e6-899b-748b934a3565.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lathonez/clicker/issues/180, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5tSJciSjlThe6S9pjCbRMBpthRiCblks5rBI_6gaJpZM4K688f .

Uriel96 commented 7 years ago

Okay, thank you. In my project I have only one provider called "Service" and I already added it but it is still giving me that error, I only have one test in a 'page' called "Dashboard". I don't know how to fix these error since what I understood from the answer is that you need to add all the providers and I already did.

msalcala11 commented 7 years ago

@Uriel96 I ran into a similar issue and resolved it by adding GestureController as a provider in test.ts. You can import GestureController from ionic-angular.

muhammedbasilsk commented 7 years ago

Adding example for @msalcala11 's answer.

import { GestureController }  from 'ionic-angular';

...

public static configureIonicTestingModule(components: Array<any>, overrideProviders: Array<any>): typeof TestBed {
    return TestBed.configureTestingModule({
      declarations: [
        ...components,
      ],
      providers: [
        App, Platform, Form, Keyboard, MenuController, NavController, GestureController
        {provide: Config, useClass: ConfigMock}
      ],
      imports: [
        FormsModule,
        IonicModule,
        ReactiveFormsModule,
      ],
    })
  }

@Uriel96 hope it helps.

Uriel96 commented 7 years ago

Thank you!! That did the work. It was straight forward after all XD