Structuring your webpack configuration for use with karma validation

I would like to create a test suite that will run with karma against my application that uses webpack to build. I have two entry points, app and vendors . They are created through my webpack.config.js file here . The resulting bundle.js file should contain both of these entry points in the generated file. My karma tests (mocha), located in test/spec/*_spec.js , currently point to specific components through queries such as:

var app = require('../src/scripts/App')

They also use the / jsx reaction, which seems to cause problems during the test run, where I get jsx errors:

Module parse failed: /Users/dmarr/src/status/test/spec/app_spec.js Line 10: Unexpected token < You may need an appropriate loader to handle this file type.

I would like the tests to run as fast as possible, as well as fast build times for testing with webpack-dev-server during development, minimizing Babel conversions only where necessary.

What do I need to do in karma.conf.js to get my builds working? Here is the karma.conf.js file I'm playing with .

Please note that I have this job without breaking the vendor package here: https://github.com/bitwise/status

Thanks for any help, Dave

+6
source share
1 answer

In a similar setup, it worked for me to disable CommonsChunkPlugin (for testing only). Give him a chance!

+1
source

Source: https://habr.com/ru/post/988252/


All Articles