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 DeepLinker! #216

Closed jorgeitenjr closed 7 years ago

jorgeitenjr commented 7 years ago

Hi, I am just trying to add a component (TopTabPage) in my page and expecting my instance to be truthy. Have someone got the same problem or/and know the solution?

FAILED TESTS:
  HomePage
    ✖ initialises
      Chrome 55.0.2883 (Mac OS X 10.11.6)
    Error: No provider for DeepLinker!
        at NoProviderError.BaseError [as constructor] (webpack:///~/@angular/core/src/facade/errors.js:24:0 <- src/test.ts:7948:34)
        at NoProviderError.AbstractProviderError [as constructor] (webpack:///~/@angular/core/src/di/reflective_errors.js:41:0 <- src/test.ts:52518:16)
        at new NoProviderError (webpack:///~/@angular/core/src/di/reflective_errors.js:72:0 <- src/test.ts:52549:16)
        at ReflectiveInjector_._throwOrNull (webpack:///~/@angular/core/src/di/reflective_injector.js:758:0 <- src/test.ts:97335:19)
        at ReflectiveInjector_._getByKeyDefault (webpack:///~/@angular/core/src/di/reflective_injector.js:786:0 <- src/test.ts:97363:25)
        at ReflectiveInjector_._getByKey (webpack:///~/@angular/core/src/di/reflective_injector.js:749:0 <- src/test.ts:97326:25)
        at ReflectiveInjector_.get (webpack:///~/@angular/core/src/di/reflective_injector.js:558:0 <- src/test.ts:97135:21)
        at TestBed.get (webpack:///~/@angular/core/bundles/core-testing.umd.js:814:0 <- src/test.ts:12226:67)
        at CompiledTemplate.proxyViewClass.AppView.injectorGet (webpack:///~/@angular/core/src/linker/view.js:109:0 <- src/test.ts:97877:45)
        at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (webpack:///~/@angular/core/src/linker/view.js:351:0 <- src/test.ts:98119:49)
    Error: Uncaught (in promise): Error: Error in ./TopTabPage class TopTabPage - inline template:0:0 caused by: No provider for DeepLinker!
        at resolvePromise (webpack:///~/zone.js/dist/zone.js:468:0 <- src/test.ts:118950:31)
        at resolvePromise (webpack:///~/zone.js/dist/zone.js:453:0 <- src/test.ts:118935:17)
        at webpack:///~/zone.js/dist/zone.js:502:0 <- src/test.ts:118984:17
        at ZoneDelegate.invokeTask (webpack:///~/zone.js/dist/zone.js:265:0 <- src/test.ts:118747:35)
        at ProxyZoneSpec.onInvokeTask (webpack:///~/zone.js/dist/proxy.js:103:0 <- src/test.ts:88858:39)
        at ZoneDelegate.invokeTask (webpack:///~/zone.js/dist/zone.js:264:0 <- src/test.ts:118746:40)
        at Zone.runTask (webpack:///~/zone.js/dist/zone.js:154:0 <- src/test.ts:118636:47)
        at drainMicroTaskQueue (webpack:///~/zone.js/dist/zone.js:401:0 <- src/test.ts:118883:35)
        at ZoneTask.invoke (webpack:///~/zone.js/dist/zone.js:339:0 <- src/test.ts:118821:25)
        at data.args.(anonymous function) (webpack:///~/zone.js/dist/zone.js:970:0 <- src/test.ts:119452:25)
lathonez commented 7 years ago

There's no provider for DeepLinker.

Try adding it to the providers in test.ts.

On Sat, 21 Jan 2017 at 08:36, Jorge Iten Jr notifications@github.com wrote:

Hi, I am just trying to add a component (TopTabPage) in my page and expecting my instance to be truthy. Have someone got the same problem or/and know the solution?

FAILED TESTS:

HomePage

✖ initialises

  Chrome 55.0.2883 (Mac OS X 10.11.6)

Error: No provider for DeepLinker!

    at NoProviderError.BaseError [as constructor] (webpack:///~/@angular/core/src/facade/errors.js:24:0 <- src/test.ts:7948:34)

    at NoProviderError.AbstractProviderError [as constructor] (webpack:///~/@angular/core/src/di/reflective_errors.js:41:0 <- src/test.ts:52518:16)

    at new NoProviderError (webpack:///~/@angular/core/src/di/reflective_errors.js:72:0 <- src/test.ts:52549:16)

    at ReflectiveInjector_._throwOrNull (webpack:///~/@angular/core/src/di/reflective_injector.js:758:0 <- src/test.ts:97335:19)

    at ReflectiveInjector_._getByKeyDefault (webpack:///~/@angular/core/src/di/reflective_injector.js:786:0 <- src/test.ts:97363:25)

    at ReflectiveInjector_._getByKey (webpack:///~/@angular/core/src/di/reflective_injector.js:749:0 <- src/test.ts:97326:25)

    at ReflectiveInjector_.get (webpack:///~/@angular/core/src/di/reflective_injector.js:558:0 <- src/test.ts:97135:21)

    at TestBed.get (webpack:///~/@angular/core/bundles/core-testing.umd.js:814:0 <- src/test.ts:12226:67)

    at CompiledTemplate.proxyViewClass.AppView.injectorGet (webpack:///~/@angular/core/src/linker/view.js:109:0 <- src/test.ts:97877:45)

    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (webpack:///~/@angular/core/src/linker/view.js:351:0 <- src/test.ts:98119:49)

Error: Uncaught (in promise): Error: Error in ./TopTabPage class TopTabPage - inline template:0:0 caused by: No provider for DeepLinker!

    at resolvePromise (webpack:///~/zone.js/dist/zone.js:468:0 <- src/test.ts:118950:31)

    at resolvePromise (webpack:///~/zone.js/dist/zone.js:453:0 <- src/test.ts:118935:17)

    at webpack:///~/zone.js/dist/zone.js:502:0 <- src/test.ts:118984:17

    at ZoneDelegate.invokeTask (webpack:///~/zone.js/dist/zone.js:265:0 <- src/test.ts:118747:35)

    at ProxyZoneSpec.onInvokeTask (webpack:///~/zone.js/dist/proxy.js:103:0 <- src/test.ts:88858:39)

    at ZoneDelegate.invokeTask (webpack:///~/zone.js/dist/zone.js:264:0 <- src/test.ts:118746:40)

    at Zone.runTask (webpack:///~/zone.js/dist/zone.js:154:0 <- src/test.ts:118636:47)

    at drainMicroTaskQueue (webpack:///~/zone.js/dist/zone.js:401:0 <- src/test.ts:118883:35)

    at ZoneTask.invoke (webpack:///~/zone.js/dist/zone.js:339:0 <- src/test.ts:118821:25)

    at data.args.(anonymous function) (webpack:///~/zone.js/dist/zone.js:970:0 <- src/test.ts:119452:25)

— 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/216, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5tSIMkvwfLBStRXLzSXKAOaEdR40C7ks5rUSj6gaJpZM4LpxiN .

jorgeitenjr commented 7 years ago

I tried, then I got: Can't resolve all parameters for DeepLinker: (?, ?, ?). The parameters are: (_app: App, _serializer: UrlSerializer, _location: Location); Is there a way to inform the provider's parameter? I also tried to create a mock to it but then: caused by:this.parent.registerChildNav is not a function

lathonez commented 7 years ago

Mocking was probably the way to go. From the limited details provided it looks like "DeepLinker" expects a parent variable with of type NavController (NavMock). I've not heard of DeepLinker and am AFK so can't be sure.

As there is no issue with the repository I am going to close this issue, please see #191 for the suggested path for getting help with general unit testing problems.

Thanks

lathonez commented 6 years ago

Had this issue with a component using ion-select, the following worked:

        {provide: DeepLinker, useFactory: () => ConfigMock.instance()},

basically mock out the deep linker with something. MMV with tabs page

SantoshNayak commented 5 years ago

Had this issue with a component using ion-select, the following worked:

        {provide: DeepLinker, useFactory: () => ConfigMock.instance()},

basically mock out the deep linker with something. MMV with tabs page

yay it's working