Testing a Simple Component import { TestBed, async } from '@angular/core/testing'; import { AppComponent } from './app.component'; describe('AppComponent Tests', () = { beforeEach(async(() = { TestBed.configureTestingModule({ declarations: [ AppComponent ], }).compileComponents(); })); it('should create the app', async(() = { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); })); it('should render greeting', async(() = { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('h1').textContent).toContain('Welcome!'); })); }); Testing Template // EX1 import { async, TestBed } from '@angular/core/testing'; import { SomeComponent } from './some.component'; beforeEach(() = { TestBed.configureTestingModule({ declarations: [ SomeComponent ], imports: [ // HttpModule, etc. ], providers: [ // { provide: ServiceA, useClass: TestServiceA } ] }); }); it('should do something', async(() = { TestBed.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
tutorial,web dev,angular,web application testing
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
tutorial,web dev,angular,web application testing
No comments:
Post a Comment