Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 of 7 tasks
dashawk opened this issue Apr 28, 2016 · 5 comments
Open
2 of 7 tasks

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

dashawk opened this issue Apr 28, 2016 · 5 comments

Comments

@dashawk
Copy link

dashawk commented Apr 28, 2016

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

  • generator-hottowel
  • Node
  • Npm

Affected platforms

  • linux
  • 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.

@brandonsherette
Copy link
Contributor

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.

@dashawk
Copy link
Author

dashawk commented Apr 28, 2016

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"
  },

@brandonsherette
Copy link
Contributor

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,

@dashawk
Copy link
Author

dashawk commented Apr 29, 2016

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?

@brandonsherette
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants