Created
November 24, 2017 08:32
-
-
Save huang-xiao-jian/d0537806bb9f794588c63589a23733e3 to your computer and use it in GitHub Desktop.
karma webpack configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @description - karma test entry | |
* @author - bornkiller <[email protected]> | |
*/ | |
/* eslint-disable */ | |
'use strict'; | |
// resolve test spec files | |
// | |
// We use the context method on `require` which Webpack created | |
// in order to signify which files we actually want to require or import. | |
// Below, `context` will be a/an function/object with file names as keys. | |
// Using that regex, we scan within `client/app` and target | |
// all files ending with `.spec.js` and trace its path. | |
// By passing in true, we permit this process to occur recursively. | |
// | |
let context = require.context('./__tests__/', true, /\.spec\.js/); | |
// Get all files, for each file, call the context function | |
// that will require the file and load it here. Context will | |
// loop and require those spec files here. | |
context.keys().forEach(context); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @description - karma webpack integration | |
* @author - huang.jian <[email protected]> | |
*/ | |
/* eslint-disable */ | |
'use strict'; | |
const WebpackKarmaConfiguration = require('@coco/webpack/webpack.karma'); | |
module.exports = function config(config) { | |
config.set({ | |
// base path that will be used to resolve all patterns (eg. files, exclude) | |
basePath: '', | |
// frameworks to use | |
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | |
frameworks: ['jasmine'], | |
// list of files / patterns to load in the browser | |
files: [ | |
'karma.bundle.js' | |
], | |
// list of files to exclude | |
exclude: [], | |
// pre-process matching files before serving them to the browser | |
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | |
preprocessors: { | |
'karma.bundle.js': ['webpack', 'sourcemap'] | |
}, | |
// Webpack karma configuration | |
webpack: WebpackKarmaConfiguration, | |
// Webpack please don't spam the console when running in karma! | |
webpackMiddleware: { noInfo: true }, | |
// Webpack blocker middleware | |
beforeMiddleware: ['webpackBlocker'], | |
// __tests__ results reporter to use | |
// possible values: 'dots', 'progress' | |
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | |
reporters: ['progress', 'coverage'], | |
coverageReporter: { | |
dir: 'coverage', | |
reporters: [ | |
{ type: 'html', subdir: 'html' }, | |
{ type: 'lcov', subdir: 'lcov' } | |
] | |
}, | |
// web server port | |
port: 9876, | |
// enable / disable colors in the output (reporters and logs) | |
colors: true, | |
// level of logging | |
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | |
logLevel: config.LOG_INFO, | |
// enable / disable watching file and executing tests whenever any file changes | |
autoWatch: false, | |
// start these browsers | |
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | |
browsers: ['Chrome'], | |
// Continuous Integration mode | |
// if true, Karma captures browsers, runs the tests and exits | |
singleRun: false, | |
// Concurrency level | |
// how many browser should be started simultaneous | |
concurrency: Infinity | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment