Skip to content

Karma config does not support angular-route #25

Description

@ElliotPsyIT

The default karma.conf.js list of files only includes angular-ui-router.js by default. But if during yo scaffolding you choose ngRoute you run into two grunt test problems.

A warning that angular-route.js isn't installed:

WARN [watcher]: Pattern "/Users/me/Angular/angular-ng-appgen/bower_components/angular-ui-router/release/angular-ui-router.js" 
does not match any file.

And, an an ugly set of errors indicating angular-route.js is not among karma.conf.js files (a part of one error):

homeService
    ✖ should return welcome message
      Chrome 41.0.2272 (Mac OS X 10.9.5)
    Error: [$injector:modulerr] Failed to instantiate module home due to:
    Error: [$injector:modulerr] Failed to instantiate module ngRoute due to:
    Error: [$injector:nomod] Module 'ngRoute' is not available! You either misspelled the module name or
 forgot to load it. If registering a module ensure that you specify the dependencies as the second 
argument.

One simple (though not elegant) solution would be to include in the generator's karma.conf.js a reference to angular-route.js along with the default angular-ui-router.js.

       files : [
            'bower_components/angular/angular.js',
            'bower_components/angular-mocks/angular-mocks.js',
            'bower_components/underscore/underscore.js',
            'bower_components/angular-ui-router/release/angular-ui-router.js', 
            ***'bower_components/angular-route/angular-route.js', ***
            'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
            'bower_components/angular-ui-utils/ui-utils.js',
            'bower_components/angular-animate/angular-animate.js',
            'bower_components/restangular/dist/restangular.js',
            'app/*/*.js',
            'app/**/**/*.js',
            'test/specs/**/**/*-spec.js'
        ],

Then, testing produces only a benign file not found warning which ever router you choose. Seems like a reasonable trade off when compared with the time it would take to build karma.conf.js dynamically :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions