0
私は角度2のコンポーネントをテストしようとしていますが、依存関係の読み込みに問題があります。角2のテストの依存関係
をテストするときにUserModule
をインポートしようとするとカルマエラーが発生します。インポートしないとコンポーネントエラーが多く発生します。
テスト・セットアップは、角度-CLIが発生するもので、私の特定のテストには、以下の
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { UserModule } from '../../user.module';
import { UserShowcaseComponent } from './user-showcase.component';
describe('UserShowcaseComponent',() => {
let component: UserShowcaseComponent;
let fixture: ComponentFixture<UserShowcaseComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [UserModule], <---------------------------------- NOTE
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UserShowcaseComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create',() => {
expect(component).toBeTruthy();
});
});
あるカルマからエラーが単にこの(これはフル出力で、何のテストが実行されていない)である。
29 11 2016 16:49:40.478:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
29 11 2016 16:49:40.479:INFO [launcher]: Launching browser Chrome with unlimited concurrency
29 11 2016 16:49:40.649:INFO [launcher]: Starting browser Chrome
29 11 2016 16:49:42.010:INFO [Chrome 53.0.2785 (Linux 0.0.0)]: Connected on socket /#Jpv1IioGnou6CQtUAAAA with id 98117142
Chrome 53.0.2785 (Linux 0.0.0) ERROR