ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

Karma/Jasmine - Failed to instantiate module #397

Open shikaan opened 7 years ago

shikaan commented 7 years ago

Hello everyone, I'm experiencing an issue while trying to lazy load files during tests. I have this subscription module which is a submodule of my app module (which has oc.lazyLoad as dependency).

app/subscription/subscription.module.js

angular.module("app.subscription", [
        'ui.router',
        'ui.bootstrap',
        'pascalprecht.translate',
        'tmh.dynamicLocale',
        'angular-ladda',
        'angularCSS',
         {
            files: [
                //@Load(subscription2, ["src/main/app/subscription/add-payment-method/**/*.js", "src/main/app/subscription/edit-payment-method/**/*.js", "src/main/app/subscription/v2/**/*.js", "!src/main/app/subscription/v2/**/*module.js", "!src/main/app/subscription/**/*specs.js"], {"base": "src/main", "posix": true})
            ],
            cache: false,
            serie: true
        }
    ]);

(I am using gulp-annotate, but I don't think that this is the problem. In any case you have the link if you want to check out the code).

app/subscription/v2/offer/offer.specs.js

describe('Service: OfferService', function () {
        beforeEach(module('app', 'app.subscription'));
        ....

When I try to launch Karma here's what I see:

Error: [$injector:modulerr] Failed to instantiate module app.subscription due to:
Error: [$injector:modulerr] Failed to instantiate module {"files":["app/subscription/add-payment-method/credit-card/credit-card.component.js","app/subscription/add-payment-method/payment-method.component.js","app/subscription/add-payment-method/paypal/paypal.component.js","app/subscription/edit-payment-method/credit-card/credit-card.component.js","app/subscription/edit-payment-method/edit-payment-method.controller.js","app/subscription/edit-payment-method/edit-payment-method.service.js","app/subscription/edit-payment-method/paypal/paypal.component.js","app/subscription/v2/activate/activate.controller.js","app/subscription/v2/activate/pricing.constant.js","app/subscription/v2/offer/billing-data/billing-data.component.js","app/subscription/v2/offer/current-plan/current-plan.component.js","app/subscription/v2/offer/edit-payment-method/edit-payment-method.controller.js","app/subscription/v2/offer/edit-payment-method/edit-payment-method.service.js","app/subscription/v2/offer/model/estimate-request.model.js","app/subscription/v2/offer/model/estimate-response.model.js","app/subscription/v2/offer/model/estimation.model.js","app/subscription/v2/offer/model/upgrade-request.model.js","app/subscription/v2/offer/offer.controller.js","app/subscription/v2/offer/offer.service.js","app/subscription/v2/offer/payment-method/payment-method.component.js","app/subscription/v2/offer/summary/summary.component.js","app/subscription/v2/offer/upgrade-plan/list.service.js","app/subscription/v2/offer/upgrade-plan/upgrade-plan.component.js","app/subscription/v2/renew/renew.controller.js","app/subscription/v2/renew/revew.service.js","app/subscription/v2/renew/upgrade-request.model.js","app/subscription/v2/review/billing-info-validation.service.js","app/subscription/v2/review/billing-info.model.js","app/subscription/v2/review/billing-info.service.js","app/subscription/v2/review/review.controller.js","app/subscription/v2/subscription.config.js","app/subscription/v2/subscription.controller.js","app/subscription/v2/thank-you/thank-you.controller.js","app/subscription/v2/upgrade/upgrade.controller.js"],"cache":false,"serie":true} due to:
Error: [ng:areq] Argument 'module' is not a function, got Object

What am I supposed to do to make this work?

Thank you in advance, Manuel

ArtemEkzarho commented 6 years ago

https://stackoverflow.com/questions/32499108/karma-jasmine-webpack-module-is-not-a-function

Maybe, this will help you)