Last active
February 8, 2018 16:27
-
-
Save CHBaker/fe81b911c52bb68a6edb718192f08357 to your computer and use it in GitHub Desktop.
Dynamically pass a FormGroup to a child component in a Karma test (Angular)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
import { ReactiveFormsModule, FormBuilder } from '@angular/forms'; | |
import { CommonModule } from '@angular/common'; | |
import { AppModule } from './app.module'; | |
import { ChildComponent } from './child.component'; | |
describe('StaticComponent', () => { | |
let component: StaticComponent; | |
let fixture: ComponentFixture<ChildComponent>; | |
beforeEach( | |
async(() => { | |
TestBed.configureTestingModule({ | |
declarations: [ | |
ChildComponent | |
], | |
imports: [ | |
CommonModule, | |
ReactiveFormsModule, | |
AppModule | |
] | |
}).compileComponents(); | |
}) | |
); | |
beforeEach(() => { | |
fixture = TestBed.createComponent(ChildComponent); | |
component = fixture.componentInstance; | |
// error occurs at 36 | |
fixture.detectChanges(); | |
}); | |
it('should be created', () => { | |
expect(component).toBeTruthy(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment