codymikol / karma-webpack

Karma webpack Middleware
MIT License
830 stars 221 forks source link

Tests fail upon moving to karma-webpack 5.0.0 #506

Closed jlave-ias closed 3 years ago

jlave-ias commented 3 years ago

Expected Behavior

All ~5,000 tests pass.

Actual Behavior

~2,500 tests fail.


Hi! I apologize that this isn't specifically a bug, just a request for clarification on changes between karma-webpack v4 -> v5. Despite hours of Googling, Stack Overflow, etc, I can't find anyone else who has had this issue.

A bit of background: Previously, we were using jasmine, karma, webpack v4, and karma-webpack to use webpack as a preprocessor, all without issue. Everything was working and tests were running in an order such that they were passing.

Cue upgrades to webpack v5 and karma-webpack v5. After upgrading both packages, about half of our 5,000 tests fail, many because of properties and methods which were set on imported modules which then carry over into other tests.

Has anything changed with the way karma-webpack handles imported modules from v4 -> v5 that would be causing this? This part of the config looks like it could be the issue, but I'm not sure how to change it to restore v4 behavior, or if that's even possible:

optimization: {
    runtimeChunk: 'single',
    splitChunks: {
      chunks: 'all',
      minSize: 0,
      cacheGroups: {
        commons: {
          name: 'commons',
          chunks: 'initial',
          minChunks: 1,
        },
      },
    },
  },

Any suggestions on what's going on are greatly appreciated. Thanks in advance.

jlave-ias commented 3 years ago

Well, I seem to have answered my own question. It appears that runtimeChunk: 'single' is what was causing the failures. They resolved upon including this in karma.conf.js:

webpack: {
  optimization: {
    runtimeChunk: false
  },
  ...
}

More info about the runtimeChunk setting here.