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.

Explain how to use in tests

See original GitHub issue

ng test keeps failing because of a null injection error, ie:

Error: StaticInjectorError(DynamicTestModule)[UserService -> NGXLogger]: 
  StaticInjectorError(Platform: core)[UserService -> NGXLogger]: 
    NullInjectorError: No provider for NGXLogger!

Please explain what to include in tests files to eliminate this error. It works fine outside the testing framework.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ateceycommented, Apr 23, 2018

Good spot that was it thanks

1reaction
dbfannincommented, Mar 26, 2018

@kathomas921, sounds like you’re not providing the logger when configuring your testing module. Can you verify that you are providing it? There also is also mock class for the logger. Try adding {provide: NGXLogger, useCLass: NGXLoggerMock} to your testing module providers (see below).

     TestBed.configureTestingModule({
       providers: [
         {provide: NGXLogger, useCLass: NGXLoggerMock},
         ...
       ],
       ...
     });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit Testing Tutorial – What is, Types & Test Example - Guru99
Unit Testing of software applications is done during the development ... The tool also allows developers to use pre-define assertion methods ...
Read more >
Unit Tests, How to Write Testable Code, and Why It Matters
In this unit testing tutorial, I intend to demonstrate that unit tests are quite easy; the real problems that complicate unit testing, and...
Read more >
Use Case and Use Case Testing Complete Tutorial
The best way to write test cases is to write the test cases for 'the Main scenario' first, and then write them for...
Read more >
Constructing tests - Center for Teaching and Learning
Designing tests is an important part of assessing students understanding of course content and their level of competency in applying what they are...
Read more >
How to Write Test Cases for Software: Examples & Tutorial
How to write effective tests and test cases can be streamlined over time. Some best practices include using strong titles, strong descriptions, ...
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