我正在尝试在应用程序中测试我们定制的 Jodit 编辑器,但即使是自动“应该创建”测试也失败了。失败消息是“未定义 Jodit”。
jodit.component.ts
import { Component, OnInit, AfterViewInit, OnDestroy, Input, Output, } from '@angular/core';
declare var Jodit: any;
@Component({
selector: 'app-jodit',
templateUrl: './jodit.component.html',
styleUrls: ['./jodit.component.css']
})
export class JoditComponent implements AfterViewInit, OnDestroy {
@Input() ... ;
@Output() ... ;
ngAfterViewInit() {
this.editor = new Jodit('#' + this.elementId, ...
});
jodit.component.spec.ts
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { JoditComponent } from './jodit.component';
describe('JoditComponent', () => {
let fixture: ComponentFixture<JoditComponent>;
let component: JoditComponent;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ JoditComponent ]
})
fixture = TestBed.createComponent(JoditComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
我真的是 Angular 和测试的新手,但我想知道我可能已经将 Jodit 变量声明为 false 或者缺少导入的某些内容。如果有人可以帮助我解决这个问题,我将不胜感激。