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 jasmine issue #123

Closed
ghost opened this issue Jan 27, 2015 · 12 comments
Closed

karma jasmine issue #123

ghost opened this issue Jan 27, 2015 · 12 comments
Labels

Comments

@ghost
Copy link

ghost commented Jan 27, 2015

I am trying the new master src with karma test runner. for first test, everything was ok. Second test, I am getting an error as soon as the module is initialized with,

beforeEach(module('***', function() {

    }));
@ocombe
Copy link
Owner

ocombe commented Jan 27, 2015

Ah that's the bug I'm trying to kill before I make a new release, is it possible to have the source causing the trouble? I haven't been able to replicate it so far

@ghost
Copy link
Author

ghost commented Jan 27, 2015

angular.module('test', [
        'oc.lazyLoad'
    ])
angular.module('test')
    .config(function($compileProvider, $logProvider, $ocLazyLoadProvider, REQUIRED) {
        // angular debugger, false for production
        $compileProvider.debugInfoEnabled(true);

        // $log debugger, false for production
        $logProvider.debugEnabled(false);

        // inject httpInterceptor Factory
        /*$httpProvider.interceptors.push('httpInterceptorFactory');*/

        $ocLazyLoadProvider.config({
            debug: false,
            events: true,
            modules: REQUIRED.modules
        });
    })
angular.module(test')
    .controller('appCtrl', function($scope, dataFactory) {
        this.test = 'hello';
        $scope.test = 'hello';
        dataFactory.user();
    });

this is pretty much it. test code,

describe('appCtrl main app controller', function() {
    var $controller;

    beforeEach(module('test', function($provide) {

    }));

    beforeEach(inject(function(_$controller_) {
        $controller = _$controller_;

    }));

    beforeEach(function() {
        window.Routing = jasmine.createSpyObj('Routing', ['generate']);
    });

    it('controller should be defined', function() {
        var $scope = {};
        var controller = $controller('appCtrl', {
            $scope: $scope
        });
        expect(controller.test).toBeDefined();
        expect($scope.test).toBeDefined();
    });

});

Even if you duplicate the same code, throws an error.

Error: [$injector:modulerr] Failed to instantiate module oc.lazyLoad due to: No module found during bootstrap, unable to init ocLazyLoad

@ocombe
Copy link
Owner

ocombe commented Jan 28, 2015

I had to change your test definition to:

beforeEach(function() {
      module('test');

      inject(function(_$controller_) {
        $controller = _$controller_;
      })
    });

But otherwhise it seems to be working (I don't have all your code so I don't know). Maybe you could give me both tests to check.
When I added the karma features, I had a problem with the initial list of modules not being properly reset, but I fixed it so this shouldn't be the problem.
Also are you sure that you're using the file from src, and not from dist ?

@ghost
Copy link
Author

ghost commented Jan 29, 2015

Can you send me your package.json & bower, or is it same as the the repo?

@ghost
Copy link
Author

ghost commented Jan 29, 2015

My tests are very basic really. Errors happen after the second test module init.

@ocombe
Copy link
Owner

ocombe commented Jan 29, 2015

Yes the same as the repo

@ghost
Copy link
Author

ghost commented Jan 29, 2015

Ok, I will give that a shot as well.

@ghost
Copy link
Author

ghost commented Jan 29, 2015

Ok, I tried it your way, and the inject part is throwing error now.

Have you tried this with 1.3.10 modules?

I will downgrade to your version -1.3.2 now to see if it makes a difference

@ghost
Copy link
Author

ghost commented Jan 29, 2015

So i tried it with your configuration, and it didn't work. As soon as I remove oclazyload, I get success. I will try some other variations.

@ghost
Copy link
Author

ghost commented Jan 29, 2015

Ok! I figured it out. I probably didn't know this to start with. Oclazyload needs to be loaded before angular-mocks in the karma.conf file.

@ghost ghost closed this as completed Jan 29, 2015
@ocombe
Copy link
Owner

ocombe commented Jan 29, 2015

Oh yes, it makes a lot of sense, I should mention it in the readme.
Sorry for making you struggle with your tests :)

@ghost
Copy link
Author

ghost commented Jan 29, 2015

Oh not at all, thank you for such a great product.

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

No branches or pull requests

1 participant