Bird
0
0

What is wrong with this TestBed setup?

medium📝 Debug Q7 of 15
Angular - Testing
What is wrong with this TestBed setup?
TestBed.configureTestingModule({
  declarations: [MyComponent],
  providers: MyService
});
AMyService cannot be provided in TestBed
Bdeclarations should include services too
Cproviders should be an array, not a single service
DMissing imports array
Step-by-Step Solution
Solution:
  1. Step 1: Check providers syntax

    providers must be an array even if it contains one service.
  2. Step 2: Validate other properties

    declarations is correct; services go only in providers; imports is optional.
  3. Final Answer:

    providers should be an array, not a single service -> Option C
  4. Quick Check:

    Providers must be array [OK]
Quick Trick: Wrap providers in an array even for one service [OK]
Common Mistakes:
  • Passing single provider without array
  • Including services in declarations
  • Assuming imports are mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes