question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"No provider for TranslateService" error unit test with universal-cli

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Test specs

Error output

Please tell us about your environment:

  • ng2-translate version: 4.2.0
  • Angular version: 2.2.3
  • Language: TypeScript 2.0.3

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10

github_iconTop GitHub Comments

38reactions
ocombecommented, Feb 8, 2017

Hello, you have to call “forRoot” when you import the module so that it creates an instance of the service: TranslateModule.forRoot().

2reactions
phatpham9commented, Feb 15, 2017

My bad. I forgot to import TranslateModule in its parent testing module. Close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - test - No provider for TranslateService - Stack Overflow
I tried your solution but it didn't change anything to the error. As a side note, the TranslateModule needs to be mocked: dev.to/lados/…...
Read more >
Nullinjectorerror: No Provider For Translate Service - ADocLib
Programmer Sought However execution ng test The test will give an error the error content is as follows: Services to be tested: Unit...
Read more >
Testing Pipes – Testing Angular
How to test simple and complex, pure and impure Angular Pipes. ... Or we provide fake dependencies, writing a unit test.
Read more >
[Debugging] NullInjectorError: No provider for {Class}!
In this video, you'll learn what the error "NullInjectorError: No provider for {Class}!" means, how to debug it, and prevent it from ...
Read more >
Angular-Karma Solution of NullInjectorError in UnitTest [ionic4]
Though it has no problems in a Service Class Testing, Component Testing occurs so many errors related to module injection. In addition, the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found