lundi 1 février 2016

Error: [$injector:unpr] Unknown provider: $routeProvider, Failed to instantiate module myApp due to

I am very new to unit testing and I am getting this really weird error when running Grunt Test.

TypeError: 'undefined' is not an object (evaluating '$websocketBackend.mock')


Error: [$injector:modulerr] Failed to instantiate module myApp due to:

Error: [$injector:unpr] Unknown provider: $routeProvider

spec.js

    describe('test d3mapping websocket', function () {
        var testScope, $controller, $websocketBackend;
        //
        //beforeEach(function() {
        //    module('myApp');
        //    module('ngWebSocket', 'ngWebSocketMock');
        //    inject(function(_$controller_, $rootScope, _$websocketBackend_) {
        //        $controller = _$controller_;
        //        testScope = $rootScope.$new();
        //
        //        $websocketBackend = _$websocketBackend_;
        //
        //    });
        //});

        describe('response', function() {

            beforeEach(function() {
                module('myApp');
                module('ngWebSocket', 'ngWebSocketMock');
                inject(function(_$controller_, $rootScope, _$websocketBackend_) {
                    $controller = _$controller_;
                    testScope = $rootScope.$new();

                    $websocketBackend = _$websocketBackend_;
                });
                $controller('MainCtrl', {
                    $scope: testScope
                });
            });

            it('should send/receive json',
                function() {
                    $websocketBackend.mock();
//server url omitted
                    $websocketBackend.expectConnect("ws://server");
                    $websocketBackend.expectSend(JSON.stringify('{"nodes":[{"name":"A6EBL","group":2,"size":5},{"name":"GBYGC","group":2,"size":5},{"name":"KORD","group":1,"size":10},{"name":"EGLL","group":1,"size":10},{"name":"DNMM","group":1,"size":10}],"links":[{"source":2,"target":1,"value":1},{"source":3,"target":1,"value":1},{"source":3,"target":1,"value":1},{"source":2,"target":1,"value":1},{"source":4,"target":1,"value":1},{"source":3,"target":1,"value":1}]}'));
                }
            );
        });
    });

    // test svg


    describe('Test D3.js with jasmine ', function () {
        var testScope;

        beforeEach(function () {

            module('myApp');
            inject(function ($controller, $rootScope) {
                testScope = $rootScope.$new();
                $controller('MainCtrl', {
                    $scope: testScope
                });
            });
        });



        describe('the svg', function () {
            it('should be created', function () {
                expect(getSvg()).not.toBeNull();
            });
        });

        function getSvg() {
            return document.getElementsByTagName('svg');
        }

    });

Any suggestions would help

Aucun commentaire:

Enregistrer un commentaire