Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the necessary Angular testing module.
Angular
TestBed.configureTestingModule({ imports: [[1]] }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using BrowserModule instead of HttpClientTestingModule
Forgetting to import any module
✗ Incorrect
The HttpClientTestingModule is used to mock HTTP requests in Angular tests.
2fill in blank
mediumComplete the code to declare the component under test.
Angular
TestBed.configureTestingModule({ declarations: [[1]] }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting modules inside declarations
Not declaring the component at all
✗ Incorrect
The component to test must be declared in the declarations array.
3fill in blank
hardFix the error in the TestBed setup to create a component fixture.
Angular
const fixture = TestBed.[1](AppComponent); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using compileComponents instead of createComponent
Trying to inject component directly
✗ Incorrect
createComponent creates a test fixture for the component.
4fill in blank
hardFill both blanks to properly configure TestBed with declarations and imports.
Angular
TestBed.configureTestingModule({ declarations: [[1]], imports: [[2]] }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping declarations and imports
Forgetting to import testing modules
✗ Incorrect
The component goes in declarations, and the HTTP testing module goes in imports.
5fill in blank
hardFill all three blanks to create a TestBed configuration with declarations, imports, and providers.
Angular
TestBed.configureTestingModule({ declarations: [[1]], imports: [[2]], providers: [[3]] }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting services in imports or declarations
Forgetting to provide services
✗ Incorrect
Declare the component, import the HTTP testing module, and provide the service for dependency injection.