Search code examples
angularjsjasminephantomjskarma-runnerfroala

Adding Froala breaks Karma Unit Tests


I've just added Froala to my Angularjs (1.5) project via bower install and it's breaking the unit tests I currently have setup. When I add 'froala' to the angular.module being defined in app.js it breaks the tests, but all of the tests pass when I remove it.

I have Froala configured in an app.js file:

angular.module('app', [ 'froala',....

I'm referencing the local/downloaded files in index.html

<link href="bower_components/froala-wysiwyg-editor/css/froala_editor.min.css" rel="stylesheet" type="text/css" />
<link href="bower_components/froala-wysiwyg-editor/css/froala_style.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="bower_components/froala-wysiwyg-editor/js/froala_editor.min.js"></script>
<script type="text/javascript" src="bower_components/froala-wysiwyg-editor/js/angular-froala.js"></script>

And this is the error I'm getting:

TypeError: undefined is not an object (evaluating 'ctrl.disableInput')

Here's the Karma configuration and an example test that's passing prior to adding froala.

Is there something in Froala that I need to configure in order to have passing tests?


Solution

  • It was a simple mistake on my part by loading angular-froala within the bower components folder. This part src="bower_components/froala-wysiwyg-editor/js/angular-froala.js" and including it within app.js angular.module('app', [ 'froala',..... I removed both of these references and only have this in the index:

    <link href="bower_components/froala-wysiwyg-editor/css/froala_editor.min.css" rel="stylesheet" type="text/css" />. 
    <link href="bower_components/froala-wysiwyg-editor/css/froala_style.min.css" rel="stylesheet" type="text/css" />. 
    <script type="text/javascript" src="bower_components/froala-wysiwyg-editor/js/froala_editor.min.js"></script>. 
    

    I followed this previous stack overflow answer regarding integrating with angular and assumed I needed to include it, but it wasn't necessary.