W dalszym ciągu staram się ogarnąć testowanie na froncie i udało mi się jak na razie wstępnie coś skonfigurować. Ale mam problem gdy staram się odpalić test dla komponentu.
To jest mój app.component.spec.ts
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {By} from "@angular/platform-browser";
import {AppComponent} from "./app.component";
import {DebugElement} from "@angular/core";
describe('App component ', () => {
let comp: AppComponent;
let fixture: ComponentFixture<AppComponent>;
let debugElement: DebugElement;
let htmlElement: HTMLElement;
// async beforeEach
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AppComponent ], // declare the test component
})
.compileComponents(); // compile template and css
}));
beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
comp = fixture.componentInstance;
debugElement = fixture.debugElement.query(By.css('div'))
htmlElement = debugElement.nativeElement;
});
it('true is true', function () {
console.log('TEST')
return expect(false).toBe(true); });
});
Jak na razie nie ma tam nic sensownego ponieważ borykam się z problemem
ncaught ReferenceError: exports is not defined
[1] at src/app/component/ts/app.component.spec.js:2
Nie mogę znaleźć rozwiązania tego. Może ktoś z was ma pomysł co jest źle.
Zamieszczam link do repo z całym kodem. Może ktoś mi powie co jest nie tak, lub wystawi mi PR z przykładem jak to powinno być poprawnie ogarnięte:
Repo na github