Testing project with Karma, Unknown provider: $$rAFProvider


from karma.con.js:

files: [

Test Code:

describe('DealCtrl', function () {

    var ctrl
        , scope;

    beforeEach(inject(function ($controller) {
        scope = {};
        ctrl = $controller('DealCtrl', {$scope: scope});

    it('should do something', function(done) {

Running karma start gives me the following error:

$ karma start
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 34.0.1847 (Mac OS X 10.9.2)]: Connected on socket jA6UYSkdnaJ-bRvoKtnS with id 23310616
Chrome 34.0.1847 (Mac OS X 10.9.2) DealCtrl should do something FAILED       
        Error: [$injector:modulerr] Failed to instantiate module ngMock due to:
        Error: [$injector:unpr] Unknown provider: $$rAFProvider
            at /Users/d/src/samples/ionic/sample/www/lib/ionic/js/ionic.bundle.js:12754:12

I looked through GitHub and couldn’t find any sample projects that use Karma for test, are there any?


hi wdbetts,

i have a similar error/ problem - did you progress ?

if so what did you do ?

there are some discussion here: https://github.com/driftyco/ionic/issues/891 - i have not yet solved it my self for unit tests (jasmine / karma) using module ngMock / $httpBackend




well i solved i by:

  1. using the lib files of https://github.com/driftyco/ionic/tree/master/config/lib (this is angular 1.2.12 - which feels awkward because the loaded angular when starting app is 1.2.16)

  2. and with a karma config looking like:

    module.exports = function(config){

    basePath : ‘…/’,

    files: [
    // Include jQuery only for testing convience (lots of DOM checking for unit tests on directives)

    exclude: [

    frameworks: [‘jasmine’],
    reporters: [‘progress’],
    port: 9876,
    colors: true,
    // possible values: ‘OFF’, ‘ERROR’, ‘WARN’, ‘INFO’, 'DEBUG’
    logLevel: ‘INFO’,
    autoWatch: true,
    captureTimeout: 60000,
    singleRun: false,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera (has to be installed with npm install karma-opera-launcher)
    // - Safari (only Mac; has to be installed with npm install karma-safari-launcher)
    // - PhantomJS
    // - IE (only Windows; has to be installed with npm install karma-ie-launcher)
    browsers: [‘Chrome’]



Thanks! this post helped me to solve the issue.
But I included the ionic.js instead of ionic-angular.js