ocombe / ocLazyLoad

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

How it should work with unit-tests? #424

Open ArtemEkzarho opened 6 years ago

ArtemEkzarho commented 6 years ago

https://github.com/ArtemEkzarho/setup_angular_lazyload_karma

Tests isn't running with lazy loaded module.

Can you help me?) Or all of this is no longer relevant?

dulcetti commented 5 years ago

@ArtemEkzarho Hi.

I put the follow code inside require.ensure:

if (process.env.NODE_ENV == 'test') {
    import('./foo.module');
} else {
    require('./foo.module');
}

And inside webpack.config.karma.js I put:

plugins: [
    new webpack.DefinePlugin({
        'process.env': { NODE_ENV: JSON.stringify('test') }
    })
]

It's not good, but it was the way I got it =P

ArtemEkzarho commented 5 years ago

Problem in two different .configs). All want to build the application in one bundle, for tests and for production. This bundle will first be tested, and then deployed to env.

My solution does not solve the problem