When writing tests run by Karma for an application that’s bundled with webpack, it’s easiest to integrate webpack and Karma directly together. In this lesson we’ll see how to utilize the karma-webpack
plugin and reuse our existing webpack configuration to preprocess our test files with webpack.
Any suggestions on how to handle the CommonsChunkPlugin? I am getting an error webpackJsonp in my testing file.
Thanks
Hey! Actually, you might like my other lessons about Webpack. Specifically this one. Basically you disable CommonsChunkPlugin
in test mode. I also recommend you give this a look to help make that easier :)
Good luck!
Things to note if dealing with typescript like me:
karma.conf.ts
for typescript files or the test won't even run (because the karma browser doesn't recognize the mime type), for example like:const karmaConfig = (config) => {
config.set({
...
mime : {
'text/x-typescript': [
'ts',
'tsx'
]
},
...
ts
extension.