Bird
0
0

How should RouterTestingModule be included in the TestBed configuration to test routing in Angular?

easy📝 Syntax Q3 of 15
Angular - Testing
How should RouterTestingModule be included in the TestBed configuration to test routing in Angular?
AAdd <code>RouterTestingModule</code> to the <code>providers</code> array
BAdd <code>RouterTestingModule</code> to the <code>declarations</code> array
CImport <code>RouterTestingModule</code> in the component's <code>@NgModule</code> decorator
DAdd <code>RouterTestingModule</code> to the <code>imports</code> array in <code>TestBed.configureTestingModule</code>
Step-by-Step Solution
Solution:
  1. Step 1: Identify where modules go in TestBed

    Modules like RouterTestingModule must be included in the imports array to be available during testing.
  2. Step 2: Understand the role of declarations and providers

    Declarations are for components, directives, and pipes; providers are for services. RouterTestingModule is a module, so it belongs in imports.
  3. Final Answer:

    Add RouterTestingModule to the imports array in TestBed.configureTestingModule -> Option D
  4. Quick Check:

    Modules go in imports, not declarations or providers [OK]
Quick Trick: Modules belong in imports array [OK]
Common Mistakes:
  • Placing RouterTestingModule in declarations
  • Adding RouterTestingModule to providers
  • Importing RouterTestingModule only in app module

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes