0

I am using Froala Editor in my component. The editor is working fine when I run the website. But, the spec.ts file is generating this error.

TypeError: this.$element.froalaEditor is not a function

Any solution?

The onAddPost function is getting covered, no problems with that. But, the test case is failing because of the error regarding Froala editor itself.

2
  • could you add your spec.ts file content?
    – Arikael
    Mar 8, 2019 at 21:20
  • Are you using angular-froala-wysiwyg? Mar 8, 2019 at 21:51

1 Answer 1

2

So, as i see you do not use template of component in your test, so you can just remove FroalaEditorModule, FroalaViewModule from imports, and add template override for your component, like:

TestBed.configureTestingModule({
   ....
})
.compileComponents()
.overrideComponent(PostsAddComponent, {
    set: {
        template: ""
    }
});

Since your component won't have template, you won't use froala components & directives, and it won't access this global script and error should disappear. Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.