NativeScript Angular 2 애플리케이션에서 매우 간단한 구성 요소 테스트를 수행하는 데 문제가 있습니다. 나는 그냥 "new Component()"를 호출 한 다음 this 테스트 예제에 표시된 것처럼 테스트하지 못하는 것 같습니다. 구성 요소에 액세스하기 위해 Angular 2 TestBed 구현을 시도하고 있습니다. 이것도 작동하지 않는 것 같습니다. 아무도 비슷한 문제에 부딪 혔거나 이와 관련된 경험이 있습니까? 시험NativeScript Angular2 앱의 테스트 구성 요소
구성 요소 :
import { Component } from "@angular/core";
@Component({
selector: "links",
templateUrl: "./components/links/links.component.html"
})
export class LinksComponent {
test = "test";
public constructor() {
}
}
테스트 :
import "reflect-metadata";
import { LinksComponent } from "../../components/links/links.component";
import { ComponentFixture, TestBed } from '@angular/core/testing';
describe("Links Component",() => {
let comp: LinksComponent;
let fixture: ComponentFixture<LinksComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ LinksComponent ],
});
fixture = TestBed.createComponent(LinksComponent);
comp = fixture.componentInstance;
});
it("will pass because this is a silly test",() => {
expect(comp.test).toEqual("test");
})
});
로그 출력 :
NativeScript/10.3 (10.3; iPhone) ../../tests/components/links.spec.js at line 0 FAILED
ReferenceError: Can't find variable: Zone
NativeScript/10.3 (10.3; iPhone): Executed 1 of 0 (1 FAILED) (0 secs/0 seNativeScript/10.3 (10.3; iPhone): Executed 1 of 0 (1 FAILED) ERROR (0.008 secs/0 secs)
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:258:24: NSUTR: completeAck
May 11 16:16:43 --- last message repeated 1 time ---
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:90:28: NSUTR-socket.io: io server disconnect
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:151:24: NSUTR: disregarding second execution
Test run failed.
아직 공식적으로 지원되지는 않지만 커뮤니티 회원이 해결할 수있는 방법에 대해서는 링크 된 문제의 토론을 참조하십시오. https://github.com/NativeScript/nativescript-angular/issues/479#issuecomment-265966999 –