Ad
How To Test A Component With Froala Editor In Karma For Angular?
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.
Ad
Answer
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.
Ad
source: stackoverflow.com
Related Questions
- → Make a Laravel collection into angular array (octobercms)
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → Angularjs not working inside laravel form
- → Analysis of Flux implementations
- → how to write react component to construct HTML DOM
- → angular ng-repeat and images in a row
- → Conditional BG Color on AngularJS
- → Should I 'use strict' for every single javascript function I write?
- → getting the correct record in Angular with a json feed and passed data
- → "Undefined is not a function" at .toBe fucntion
- → angularjs data binding issue
- → Angular / JavaScript auto hydrate an instance
- → Convert generic text string in json object into valid url using Angular
Ad