wardbell / bardjs

Spec helpers for testing angular v.1.x apps with Mocha, Jasmine and QUnit
MIT License
178 stars 34 forks source link

cannot test my routes using bardjs #14

Closed caninojories closed 9 years ago

caninojories commented 9 years ago

this is the error: Error: [$injector:unpr] Unknown provider: routerHelperProvider <- routerHelper

caninojories commented 9 years ago

im using the sample in the hottowel test of john papa /* jshint -W117, -W030 */ 'use strict'; describe('main route', function () { describe('state', function () { var controller; var view = '/client/main/index.html';

    beforeEach(function() {
        module('app.main', bard.fakeToastr);
        bard.inject('$httpBackend', '$location', '$rootScope', '$state', '$templateCache');
    });

    beforeEach(function() {
        $templateCache.put(view, '');
    });

    it('should map state admin to url /admin ', function() {
        expect($state.href('main', {})).to.equal('/');
    });

    it('should map /admin route to admin View template', function () {
        expect($state.get('main').templateUrl).to.equal(view);
    });

    it('of admin should work with $state.go', function () {
        $state.go('main');
        $rootScope.$apply();
        expect($state.is('main'));
    });
});

});

caninojories commented 9 years ago

this is my route (function() { 'use strict';

angular .module('app.main') .run(appRun);

appRun.$inject = ['routerHelper'];
/*ngInject*/
function appRun(routerHelper) {
  routerHelper.configureRoutes(getRoutes());
}

function getRoutes() {
  return [{
    state: 'main',
    config: {
      url: '/',
      templateUrl: '/client/main/index.html',
      controller: 'Main as vm',
      title: 'Main'
    }
  }];
}

}());

wardbell commented 9 years ago

Doesn't look like a bard problem. Are you sure the routerHelper.js file is picked up by your test harness? That is NOT the same thing as being sure it is picked up when the app runs.

caninojories commented 9 years ago

sorry.. i forgot to inject my dependency(app.core) in my admin module.. thanks for the answer..

setuk commented 8 years ago

what did you do to inject your dependency I am having the same issue - the dependency seems to be there in the module I am using though!