Skip to content

Commit 3ec4f61

Browse files
cexbrayatvikerman
authored andcommitted
fix(@schematics/angular): remove unneeded debugElement in test
The generate tests in `app.component.spec.ts` are using `fixture.debugElement.componentInstance` whereas we can directly use `fixture.componentInstance`. This fixes the generated test to show a better example to users discovering unit tests.
1 parent 3c9305b commit 3ec4f61

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/schematics/angular/application/other-files/app.component.spec.ts.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ describe('AppComponent', () => {
1616

1717
it('should create the app', () => {
1818
const fixture = TestBed.createComponent(AppComponent);
19-
const app = fixture.debugElement.componentInstance;
19+
const app = fixture.componentInstance;
2020
expect(app).toBeTruthy();
2121
});
2222

2323
it(`should have as title '<%= name %>'`, () => {
2424
const fixture = TestBed.createComponent(AppComponent);
25-
const app = fixture.debugElement.componentInstance;
25+
const app = fixture.componentInstance;
2626
expect(app.title).toEqual('<%= name %>');
2727
});
2828

2929
it('should render title', () => {
3030
const fixture = TestBed.createComponent(AppComponent);
3131
fixture.detectChanges();
32-
const compiled = fixture.debugElement.nativeElement;
32+
const compiled = fixture.nativeElement;
3333
expect(compiled.querySelector('.content span').textContent).toContain('<%= name %> app is running!');
3434
});
3535
});

0 commit comments

Comments
 (0)