From c604fe2062571a1a20aa59c2f0c3843d1aaedb9f Mon Sep 17 00:00:00 2001 From: laco0416 Date: Tue, 4 Oct 2016 01:44:46 +0900 Subject: [PATCH] fix(generate): make generated component.spec consistent with AppComponent spec --- .../files/__path__/__name__.component.spec.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/angular-cli/blueprints/component/files/__path__/__name__.component.spec.ts b/packages/angular-cli/blueprints/component/files/__path__/__name__.component.spec.ts index e7ed84fac3d2..bd054ef7d49a 100644 --- a/packages/angular-cli/blueprints/component/files/__path__/__name__.component.spec.ts +++ b/packages/angular-cli/blueprints/component/files/__path__/__name__.component.spec.ts @@ -4,8 +4,18 @@ import { TestBed, async } from '@angular/core/testing'; import { <%= classifiedModuleName %>Component } from './<%= dasherizedModuleName %>.component'; describe('Component: <%= classifiedModuleName %>', () => { - it('should create an instance', () => { - let component = new <%= classifiedModuleName %>Component(); - expect(component).toBeTruthy(); + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + <%= classifiedModuleName %>Component + ], + }); }); + + it('should create an instance', async(() => { + let fixture = TestBed.createComponent(<%= classifiedModuleName %>Component); + let cmp = fixture.debugElement.componentInstance; + expect(cmp).toBeTruthy(); + })); });