I'm currently testing a custom Jodit editor in my app, but even the automatic 'should create' test is failing with an error message of 'Jodit is not defined'.
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();
});
});
I am fairly new to Angular and testing in general, so I am wondering if I have incorrectly declared the Jodit variable or if I have missed something in the imports. Any help would be greatly appreciated.