【发布时间】:2018-11-08 13:20:27
【问题描述】:
我对业力测试有疑问。当我运行测试时,有时会出现以下错误:
HeadlessChrome 70.0.3538 (Windows 10.0.0) ERROR
{
"message": "An error was thrown in afterAll\n[object ErrorEvent] thrown",
"str": "An error was thrown in afterAll\n[object ErrorEvent] thrown"
}
如果我不进行任何更改并再次运行相同的测试,测试可能不会失败。
我了解到这可能是异步测试的错误 (https://github.com/karma-runner/karma/issues/2811#issuecomment-407600850),因此我删除了所有异步和 fakeasync 测试。但是,这仍然不能解决问题。如果没有 async 和 fakeasync 测试,我有这个错误:
HeadlessChrome 70.0.3538 (Windows 10.0.0) MyComponent should create FAILED
[object ErrorEvent] thrown
HeadlessChrome 70.0.3538 (Windows 10.0.0): Executed 50 of 55 (1 FAILED) (0 secs / 0 secs)
但是在这个组件的测试中我找不到错误:
describe('MyComponent', () => {
let component: MyComponent;
let fixture: ComponentFixture<MyComponent>;
const zipService = jasmine.createSpyObj('ZipService', {
search: of([])
});
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [MyComponent, OnOffSwitchComponent, TranslatePipeMock],
imports: [
NgbModule.forRoot(),
FormsModule,
ReactiveFormsModule
],
providers: [
{provide: TranslateService, useValue: translateServiceMock()},
{provide: UtilService, useValue: utilMock()},
{provide: ZipService, useValue: zipService}
]
}).compileComponents();
fixture = TestBed.createComponent(MyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
有人知道它可能是什么吗?
【问题讨论】:
标签: angular karma-jasmine karma-runner