× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Not getting what you expect when running a Karma test?

Dale Lotts
Feb 07, 2016
<p>There are lots of moving parts when running Karma tests. If you are not seeing the results you expect, here are a few thinkgs to check:</p> <ul> <li>Is the module included in your test? <ul> <li>beforeEach(module('name.of.the.module.containing.the.directive'));</li> </ul> </li> <li>Is Karma configured correctly? <ul> <li>plugins: <span style="background-color:rgb(255, 255, 255); color:rgb(102, 102, 102)">List of plugins to load. A plugin can be a string (in which case it will be required by Karma) or an inlined plugin - Object. By default, Karma loads all sibling NPM modules which have a name starting with </span><code>karma-*</code><span style="background-color:rgb(255, 255, 255); color:rgb(102, 102, 102)">. i.e. </span><code>['karma-jasmine']</code><span style="background-color:rgb(255, 255, 255); color:rgb(102, 102, 102)">, </span><code>['karma-mocha']</code><span style="background-color:rgb(255, 255, 255); color:rgb(102, 102, 102)"> </span></li> <li>frameworks: <span style="background-color:rgb(255, 255, 255); color:rgb(102, 102, 102)">List of test frameworks you want to use. Typically, you will set this to </span><code>['jasmine']</code><span style="background-color:rgb(255, 255, 255); color:rgb(102, 102, 102)">, </span><code>['mocha']</code><span style="background-color:rgb(255, 255, 255); color:rgb(102, 102, 102)"> or </span><code>['qunit']</code></li> <li>files: An array <span style="background-color:rgb(255, 255, 255); color:rgb(102, 102, 102)">of files/patterns to load in the browser.  The order of the files/patterns determines the order in which files are included in the browser. List jQuery first</span></li> </ul> </li> <li>Are the teplates pre-loaded into the template cache?</li> </ul>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus