Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test fails "No provider for $uiRouter" #29

Closed
ghost opened this issue Jan 20, 2017 · 1 comment
Closed

Unit test fails "No provider for $uiRouter" #29

ghost opened this issue Jan 20, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Jan 20, 2017

I've read through https://github.com/ui-router/ng1-to-ng2 and my app is working great, ng1 routing still works and now I can use uiSref in my ng2 component. But my unit test fails for the ng2 component that is using uiSref.

Here's the code for the unit test and the app.module
https://gist.github.com/miked1090/d6a2e99f8e3dcaa6f27a9b2b7d5840a4

In the test.component.html there's an uiSref, if I comment it out the test runs fine, otherwise it fails with
"No provider for $uiRouter".

This is also a component that is not registered with the router, it's just a small component that is being used on the page.

Any help would be much appreciated, thanks.

Edit: I made some changes and removed importing AppModule in the spec file and instead declared the component in there. This fixes the issue of "No provider for $uiRouter", but now I get an error saying [uiParams] is not a valid attribute for the 'a' tag.

@ghost
Copy link
Author

ghost commented Jan 21, 2017

Fixed it by changing my Testbed configuration to

TestBed.configureTestingModule({
imports: [UIRouterModule.forRoot({ useHash: true })],
declarations: [TestComponent],
providers: [{ provide: TestService, useValue: testService}
]
})

@ghost ghost closed this as completed Jan 21, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants