Lazy loaded modules for Jasmine tests. Angularjs

51 views
Skip to first unread message

ar...@reply.io

unread,
May 2, 2018, 5:08:20 PM5/2/18
to karma-users
I have some lazy loaded modules in my app.
But I cannout use them for my jasmine tests. I cannot init/load module inside beforeEach or where else
And I couldn't find any information on this question.
 Is it possible to do for my application.

my karma config: 

config.set({

       plugins: [

           require('karma-babel-preprocessor'),

           require('karma-chrome-launcher'),

           require('karma-jasmine'),

           require('karma-phantomjs-launcher'),

           require('karma-safari-launcher'),

           require('karma-spec-reporter'),

       ],

       preprocessors: {

           'app/**/*.spec.js': ['babel'],

           'app/components/my.lazy.module.js': ['babel']

       },

       babelPreprocessor: {

           options: {

               presets: ['es2015'],

               plugins: ['syntax-dynamic-import']

           }

       },

       files: [

           'app/dest/app.js',

           'app/dest/*.bundle.js',

           'app/components/my.lazy.module.js',

           'node_modules/angular-mocks/angular-mocks.js',

           'node_modules/babel-polyfill/dist/polyfill.js',

           'app/**/*.spec.js'

       ],


        frameworks: [

           'jasmine'

       ],


        reporters: [

           'spec'

       ],


I tried load it something like that 

beforeEach(inject(($ocLazyLoad) => {

       import(/* webpackChunkName: "my.lazy" */ 'base/app/components/my.lazy.module.js')

           .then(mod => {

               return $ocLazyLoad.inject(mod.MyLazyModule);

           })

   }));


Can it be done in angularjs with webpack? What I'm doing wrong? 
I will answer any clarifying questions. Please, help me)



Reply all
Reply to author
Forward
0 new messages