Running only single changed test file using Karma with Webpack -


i've got working karma setup, using webpack. whenever modify either test file or of dependencies, all of tests run. good, i'd run minimum number of tests. if change test file, should run test file. if change source file, should run whatever test files have source file dependency (via require).

here's relevant portion of karma.config.js:

files: [   {     pattern: '**/*.test.js',     watched: true,     included: true,     served: true   }, ],  preprocessors: {   '**/*.test.js': ['webpack'] },  webpack: {   resolve: {     root: path.join(__dirname, '..', 'webpack'),     extensions: ['', '.js', '.jsx'],   },    module: {     loaders: [       {         test: /.jsx?$/,         loader: 'babel-loader',         exclude: [/node_modules/],         query: {           presets: ['es2015', 'react']         }       },     ]   }, }, 

the complete karma.config.js file in gist.

i'm familiar solutions mentioned in other questions, involving process.env.npm_config_single_file, that's not i'm trying do.

based on config above, i'm expecting handle each file separate webpack, implied documentation @ top of webpack/karma-webpack. instead, seem single webpack 2 chunks, per log:

                      asset     size  chunks             chunk names employee_list_entry.test.js  1.07 mb       0  [emitted]  employee_list_entry.test.js employer_list_entry.test.js  1.07 mb       1  [emitted]  employer_list_entry.test.js chunk    {0} employee_list_entry.test.js (employee_list_entry.test.js) 1.01 mb 

it rebuilds both chunks when save 1 test file.

instead of using watch mode of karma seems restricted executing all files, might want apply watch mode of webpack:

https://webpack.js.org/configuration/watch/

also see following related questions gulp , grunt:

karma run single test

getting grunt karma run 1 unit test


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -