generator-hottowel icon indicating copy to clipboard operation
generator-hottowel copied to clipboard

Karma Test Error: $$sanitizeUri must define $get method

Open dashawk opened this issue 8 years ago • 5 comments

Issue details

I created a sample test for my controller but I keep getting this error karma test

controller.js

(function () {
    'use strict';

    angular
        .module('app.activities')
        .controller('ActivityDetailsControllerTwo', ActivityDetailsControllerTwo);

    /** @ngInject */
    function ActivityDetailsControllerTwo() {
        var vm = this;

        vm.test = 'test';
    }
}());

I tried a simple test spec.js

describe('Activity Details', function () {
    var controller;

    beforeEach(function () {
        bard.appModule('app.activities');
        bard.inject('$controller', '$rootScope');
    });

    beforeEach(function () {
        controller = $controller('ActivityDetailsControllerTwo', { $scope: $rootScope.$new() });
        $rootScope.$apply();
    });

    bard.verifyNoOutstandingHttpRequests();

    describe('Activities Controller', function () {
        it('should be true', function () {
            expect(1).to.Be(1);
        });
    });
});

Please specify which version of generator-hottowel, node and npm you're running

  • [x] generator-hottowel
  • [ ] Node
  • [ ] Npm

Affected platforms

  • [ ] linux
  • [X] windows
  • [ ] OS X
  • [ ] other (please specify which)

Which gulp command are you running ?

I tried it with gulp test or karma start. Even created intelliJ Runner, still the same results.

dashawk avatar Apr 28 '16 07:04 dashawk

What versions of angular and angular-sanitize are you using? Current version of hottowel is using version 1.5.3 for both of them.

From my understanding, the issue may be the case of miss-match versions of angular and angular-sanitize.

brandonsherette avatar Apr 28 '16 08:04 brandonsherette

I am using angularjs 1.5.5 and angular-sanitize 1.5.5

Here is some bits of my bower.json file.

"dependencies": {
    "jquery": "^2.1.4",
    "angular": "1.5.0-rc.1",
    "angular-sanitize": "^1.4.5",
    "bootstrap": "^3.3.5",
    "extras.angular.plus": "^0.9.2",
    "font-awesome": "^4.3.0",
    "moment": "^2.10.3",
}
...
"resolutions": {
    "angular": "1.5.5"
  },

dashawk avatar Apr 28 '16 08:04 dashawk

I was able to recreate a similar error with a custom provider without a $get method. Check bower_components/angular-sanitize/angular-sanitize.js and see if it has a $get method.

You may even want to try reinstalling angular and angular-sanitize.

bower uninstall angular angular-sanitize
bower install

One thing to note, from the looks of it you may not be using the current version of hottowel,

brandonsherette avatar Apr 28 '16 12:04 brandonsherette

I actually tried to use different versions of angular and angular-sanitize, event reinstalling it but still I got the same error.

This must be really an issue in angular at #13794.

Yes my hottowel version is not the current version. Is there a way to update it without breaking my project?

dashawk avatar Apr 29 '16 00:04 dashawk

Not sure if this is the best way to update without messing your current project, but after you update the generator with npm update generator-hottowel -g, you can just create a new hottowel app and copy over your client and server code into the new hottowel app you created. If you added any other bower or node_modules to your application, you will need to re-add them, but shouldn't take to long to do.

One thing to note, the current version hottowel uses jscs for validating your code style, so you may generate quite a few errors with your code if it's not styled a certain way (it will tell you what you need to change).

Or you could try just uninstall all node and bower dependencies and and reinstall with the current node and bower files in hottowel with the correct versions.

For a quick reference, you can compare your package.json and bower.json with the current version of hottowel at the following links.

https://github.com/johnpapa/generator-hottowel/blob/master/app/templates/_package.json https://github.com/johnpapa/generator-hottowel/blob/master/app/templates/_bower.json

I personally would probably go the update the generator route, just so you have a clean slate with hottowel, and testing works in the current version with all associated dependencies.

brandonsherette avatar Apr 29 '16 16:04 brandonsherette