python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 7, Interview Questions Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
Isolated unit tests vs. Angular testing utilities

What Are Angular Testing Utilities? [Angular 4 and Angular 2]

The Angular Testing utilities include the TestBed class and helper functions from the test libraries - @angular/core/testing.

The TestBed class is one of the principal Angular testing utilities!

The TestBed class is responsible for configuring and initializing the environment that we are going to write our tests in by calling TestBed.configureTestingModule.

Stayed Informed - Angular 2 Docs with Examples
Stayed Informed - Angular 4 Docs with Examples

The TestBed.configureTestingModule is used to define the environment that we want our component under test to live in.

The Angular Testing utility APIs are –
1.     getTestBed
2.     async
3.     fakeAsync
4.     tick
5.     inject
6.     discardPeriodicTasks
7.     flushMicrotasks
8.     ComponentFixtureAutoDetect     

The most important static methods are –
1.     configureTestingModule
2.     compileComponents
3.     createComponent
4.     overrideModule
5.     overrideComponent
6.     overrideDirective
7.     overridePipe
8.     get
9.     initTestEnvironment
10.  resetTestEnvironment

Example As –
beforeEach(() => {
  fixture = TestBed.configureTestingModule({
    declarations: [YourComponent ]

References -

I hope you are enjoying with this post! Please share with you friends. Thank you!!

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like Powered by Blogger.
ASK Questions