
Previously, only e2e tests were run for docs examples on CI. As a result, unit tests (which are included in the zipped archives we provide for users to download and play with the examples locally) were often outdated and broken. This commit configures specific docs examples that have meaningful unit tests to run them on CI (via the `run-example-e2e.js` script). Where necessary, the unit tests are fixed to ensure they pass and reflect the changes in the corresponding component/service. This commit also removes some auto-generated unit tests that are not meaningful (e.g. make trivial assertions, such that a component instance is truthy) and are often broken anyway (e.g. because the corresponding component has been changed in ways that make the tests fail). PR Close #36143
34 lines
948 B
TypeScript
34 lines
948 B
TypeScript
import { AppComponent } from './app.component';
|
|
|
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
import { By } from '@angular/platform-browser';
|
|
import { DebugElement } from '@angular/core';
|
|
|
|
describe('AppComponent', () => {
|
|
let de: DebugElement;
|
|
let comp: AppComponent;
|
|
let fixture: ComponentFixture<AppComponent>;
|
|
|
|
beforeEach(async(() => {
|
|
TestBed.configureTestingModule({
|
|
declarations: [ AppComponent ]
|
|
})
|
|
.compileComponents();
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
fixture = TestBed.createComponent(AppComponent);
|
|
comp = fixture.componentInstance;
|
|
de = fixture.debugElement.query(By.css('h1'));
|
|
});
|
|
|
|
it('should create component', () => expect(comp).toBeDefined() );
|
|
|
|
it('should have expected <h1> text', () => {
|
|
fixture.detectChanges();
|
|
const h1 = de.nativeElement;
|
|
expect(h1.textContent).toMatch(/angular/i,
|
|
'<h1> should say something about "Angular"');
|
|
});
|
|
});
|