Testing Asynchronous Code with FakeAsync in Angular - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Sunday, May 5, 2019

Testing Asynchronous Code with FakeAsync in Angular

When creating automated unit tests in Ionic and Angular applications we would typically follow a process like this: Set up the testing environment Run some code Make assertions as to what should have happened This process is also commonly referred to as AAA (Arrange, Act, Assert). I don't plan to provide an introduction to unit testing in this tutorial (this serves as a good starting point for testing Ionic applications), but a typical test might look something like this: import { TestBed, ComponentFixture, async } from '@angular/core/testing'; import { IonicModule } from 'ionic-angular'; import { MyApp } from './app.component'; import { LoginPage } from '../pages/login/login'; let comp: MyApp; let fixture: ComponentFixtureMyApp; describe('Component: Root Component', () = { beforeEach(async(() = { TestBed.configureTestingModule({ declarations: [MyApp], providers: [ ], imports: [ IonicModule.forRoot(MyApp) ] }).compileComponents(); })); beforeEach(() = { fixture = TestBed.createComponent(MyApp); comp = fixture.


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 blogtwitter 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.


No comments:

Post a Comment