【发布时间】:2018-09-07 14:19:56
【问题描述】:
我有一个使用动画库 Mojs 的组件。由于 MoJs 元素,随 spec.ts 文件开箱即用的创建组件测试失败。我不确定如何在 spec.ts 文件中提供这个库,以便至少成功创建组件的这个测试通过。
我得到的错误是:'Cannot read property 'CustomShape' of undefined'
这个 CustomShape 的实现看起来像:
class paperOutlineTopCorner3 extends mojs.CustomShape {
getShape () { return '<path d="123XYZ"/>'; }
}
我当前的 spec.ts 文件:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CallbackComponent } from './callback.component';
import { requiredTestModules } from '../testing/import.helpers';
describe('CallbackComponent', () => {
let component: CallbackComponent;
let fixture: ComponentFixture<CallbackComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CallbackComponent ],
imports: [requiredTestModules]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CallbackComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
任何帮助/建议将不胜感激
【问题讨论】:
标签: angular unit-testing jasmine karma-jasmine angular6