Comparing Angular NgModule and TestBed Side by Side
TestBed
’s configureTestingModule
method looks similar to NgModule
in usage. Check out this side by side example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@NgModule({ | TestBed.configureTestingModule({
|
declarations:[ | declarations: [
AppComponent, | AppComponent,
CurrentResultsComponent, | CurrentResultsComponent,
ResultsLogComponent | ResultsLogComponent
], | ],
imports: [ | imports: [
BrowserModule, | FormsModule,
FormsModule, | HttpModule
HttpModule |
], | ],
providers: [ | providers: [
StockRetrieverService | {
], | provide: StockRetrieverService,
| useClass: TestStockRetrieverService
| }
| ]
|
|
bootstrap: [AppComponent] |
}) |
export class AppModule { } | });
For a full example see the https://github.com/kendaleiv/angular-testing repository.
This post is licensed under CC BY 4.0 by the author.