Karma-webpack takes ~2 minutes to load
See original GitHub issueUsing 1.7.0 and webpack 1.12
When I start my unit tests I get an the following logs with loglevel: config.LOG_DEBUG
02 03 2016 09:19:46.010:DEBUG [plugin]: Loading karma-* from /.../node_modules
02 03 2016 09:19:46.013:DEBUG [plugin]: Loading plugin /.../node_modules/karma-chai.
02 03 2016 09:19:46.014:DEBUG [plugin]: Loading plugin /.../node_modules/karma-chai-as-promised.
02 03 2016 09:19:46.015:DEBUG [plugin]: Loading plugin /.../node_modules/karma-chai-sinon.
02 03 2016 09:19:46.017:DEBUG [plugin]: Loading plugin /.../node_modules/karma-chrome-launcher.
02 03 2016 09:19:46.021:DEBUG [plugin]: Loading plugin /.../node_modules/karma-coverage.
02 03 2016 09:19:46.207:DEBUG [plugin]: Loading plugin /.../node_modules/karma-firefox-launcher.
02 03 2016 09:19:46.209:DEBUG [plugin]: Loading plugin /.../node_modules/karma-mocha.
02 03 2016 09:19:46.210:DEBUG [plugin]: Loading plugin /.../node_modules/karma-nyan-reporter.
02 03 2016 09:19:46.257:DEBUG [plugin]: Loading plugin /.../node_modules/karma-sinon.
02 03 2016 09:19:46.258:DEBUG [plugin]: Loading plugin /.../node_modules/karma-webpack.
02 03 2016 09:21:50.288:DEBUG [karma]: List of files has changed, trying to execute
02 03 2016 09:21:50.289:WARN [karma]: No captured browser, open http://localhost:9876/
02 03 2016 09:21:50.291:DEBUG [watcher]: Watching "/.../app/index.test.js"
02 03 2016 09:21:50.294:INFO [karma]: Karma v0.13.19 server started at http://localhost:9876/
02 03 2016 09:21:50.298:INFO [launcher]: Starting browser Firefox
Notice that loading the karma-webpack takes a little under two minutes to load before the next line runs?
I inherited a fairly large app it has over 640 unit tests. But by far the thing that takes the longest is waiting for karma-webpack module to load. I am trying to figure out why it takes so long to load.
Currently each test is required by the file that it is testing, like so:
// inside custom-date-form directive
if (process.env.NODE_ENV === 'test') {
require('./custom-date-form.test')(ngModule)
}
I have tried to fix it with a few configuration tweaks but I haven’t seen any results. Is there a way I can figure out exactly why it is taking so long to load?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Karma-webpack takes ~5 minutes to load · Issue #281 - GitHub
It is because Karma treats every test file as an entry point with Webpack, so builds will be really slow because it will...
Read more >Karma Webpack preprocessor is slow - Stack Overflow
webpack preprocessor is working for 6-8 minutes, constantly consuming 13% CPU. Simple Can I optimize this somehow? Simple npm start
Read more >Speed up Webpack compilation for Karma tests - GitLab.org
Even if no file has changed, Webpack compilation takes a quarter of the time (more than 30 seconds) of running the Karma tests:...
Read more >Build Performance - webpack
This guide contains some useful tips for improving build/compilation performance. General. The following best practices should help, whether you're running ...
Read more >Create a React app using Webpack 5 + Babel + Karma + ...
So, in the following steps, we will start the first part of our tutorial by setting up our project with React, Webpack, and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I am seeing a similar problem. From what I have found out so far, it looks like
karma-webpacktriggers an initial Webpack run right when it is initialized. I was able to optimize test runtime (also on subsequent karma runs) by removing unneededentryitems from the Webpack config used bykarma.webpackand moving to the “Alternative usage” proposed in the Readme. Beforekarma-webkitwas basically recompiling the whole bundle for each test file.@hankthewhale no and unfortunately I no longer have access to the project where this is an issue.