我正在开发一个github存储库(带有角度4和angular-cli),我有一些测试,Karma和Jasmine在master分支中工作.
现在我正在尝试添加延迟加载功能,我已经创建了一个新的分支,你可以在这里看到.
问题是,之前的测试,现在他们没有.这很有趣,因为只有延迟加载模块的测试失败了......
这是代码和错误:
import {async, TestBed} from '@angular/core/testing';
import {APP_BASE_HREF} from '@angular/common';
import {AppModule} from '../../app.module';
import {HeroDetailComponent} from './hero-detail.component';
describe('HeroDetailComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [AppModule
],
providers: [
{provide: APP_BASE_HREF, useValue: '/'}
],
}).compileComponents();
}));
it('should create hero detail component', (() => {
const fixture = TestBed.createComponent(HeroDetailComponent);
const component = fixture.debugElement.componentInstance;
expect(component).toBeTruthy();
}));
});
Run Code Online (Sandbox Code Playgroud)
错误是这样的:
Chrome 58.0.3029 (Mac OS X 10.12.6) HeroDetailComponent should create hero detail component FAILED
Error: Illegal …Run Code Online (Sandbox Code Playgroud)