Error: No provider for DeepLinker!


#1

I am testing my Ionic 2 application . I was able to run tests for my services . But I am unable to test my components. I am using this tutoral for unit testing. I have made changes according to the changes in his github repo. While testing, I get an error ,

Error: No provider for DeepLinker! at NoProviderError.Error (native) at NoProviderError.BaseError [as constructor] (webpack:///home/raj/ionic/bookemon/~/@angular/core/src/facade/errors.js:24:0 <- src/test.ts:4082:34) at NoProviderError.AbstractProviderError [as constructor] (webpack:///home/raj/ionic/bookemon/~/@angular/core/src/di/reflective_errors.js:42:0 <- src/test.ts:30215:16) at new NoProviderError (webpack:///home/raj/ionic/bookemon/~/@angular/core/src/di/reflective_errors.js:73:0 <- src/test.ts:30246:16) at ReflectiveInjector_._throwOrNull (webpack:///home/raj/ionic/bookemon/~/@angular/core/src/di/reflective_injector.js:761:0 <- src/test.ts:63303:19) at ReflectiveInjector_._getByKeyDefault (webpack:///home/raj/ionic/bookemon/~/@angular/core/src/di/reflective_injector.js:789:0 <- src/test.ts:63331:25) at ReflectiveInjector_._getByKey (webpack:///home/raj/ionic/bookemon/~/@angular/core/src/di/reflective_injector.js:752:0 <- src/test.ts:63294:25) at ReflectiveInjector_.get (webpack:///home/raj/ionic/bookemon/~/@angular/core/src/di/reflective_injector.js:561:0 <- src/test.ts:63103:21) at TestBed.get (webpack:///home/raj/ionic/bookemon/~/@angular/core/bundles/core-testing.umd.js:817:0 <- src/test.ts:7950:67) at ElementInjector.get (webpack:///home/raj/ionic/bookemon/~/@angular/core/src/linker/element_injector.js:29:0 <- src/test.ts:63494:48) Error: Uncaught (in promise): Error: Error in ./TabsPage class TabsPage - inline template:0:0 caused by: No provider for DeepLinker! at resolvePromise (webpack:///home/raj/ionic/bookemon/~/zone.js/dist/zone.js:468:0 <- src/test.ts:100208:31) at resolvePromise (webpack:///home/raj/ionic/bookemon/~/zone.js/dist/zone.js:453:0 <- src/test.ts:100193:17) at webpack:///home/raj/ionic/bookemon/~/zone.js/dist/zone.js:502:0 <- src/test.ts:100242:17 at ZoneDelegate.invokeTask (webpack:///home/raj/ionic/bookemon/~/zone.js/dist/zone.js:265:0 <- src/test.ts:100005:35) at ProxyZoneSpec.onInvokeTask (webpack:///home/raj/ionic/bookemon/~/zone.js/dist/proxy.js:103:0 <- src/test.ts:27619:39) at ZoneDelegate.invokeTask (webpack:///home/raj/ionic/bookemon/~/zone.js/dist/zone.js:264:0 <- src/test.ts:100004:40) at Zone.runTask (webpack:///home/raj/ionic/bookemon/~/zone.js/dist/zone.js:154:0 <- src/test.ts:99894:47) at drainMicroTaskQueue (webpack:///home/raj/ionic/bookemon/~/zone.js/dist/zone.js:401:0 <- src/test.ts:100141:35)

test.ts which configure the test looks like this .

    export class TestUtils {
    
      public static beforeEachCompiler(components: Array<any>): Promise<{fixture: any, instance: any}> {
        return TestUtils.configureIonicTestingModule(components)
        .compileComponents().then(() => {
          let fixture: any = TestBed.createComponent(components[0]);
          return {
            fixture: fixture,
            instance: fixture.debugElement.componentInstance,
          };
        });
      }
    
      public static configureIonicTestingModule(components: Array<any>): typeof TestBed {
        return TestBed.configureTestingModule({
          declarations: [
          ...components,
          ],
          providers: [
          App, Platform, Form, LoadingController, FormBuilder, ToastController, AlertController,
          { provide: NavController, useClass: NavMock},
          { provide: Config, useClass: ConfigMock},
          { provide: Authentication, useClass: AuthMock},
          { provide: Bookemon, useClass: BookMock}
          ],
          imports: [
          FormsModule,
          IonicModule,
          ReactiveFormsModule,
          ],
        });
      }
    } 

And my tests for TabsPage which is a simple tab page in ionic is,
import { ComponentFixture, async } from '@angular/core/testing'; import { TestUtils } from '../../test'; import { TabsPage } from './tabs'; let fixture: ComponentFixture<TabsPage> = null; let instance: any = null; describe('Tabs component',()=>{ beforeEach(async(() => TestUtils.beforeEachCompiler([TabsPage]).then(compiled => { fixture = compiled.fixture; instance = compiled.instance; }))); it('initialises', () => { expect(1).toBeTruthy(); }); })

What is going on here? What is DeepLinker. Where is the error happening. Error happen while compiling this test itself.


How can we write unit test or e2e test for ionic2?