forked from react-boilerplate/react-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Karma config to webpack folder, make karma test single run
- Loading branch information
Showing
3 changed files
with
22 additions
and
136 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,38 @@ | ||
// Karma configuration | ||
var path = require('path'); | ||
var webpackConfig = require('./webpack.test.babel'); | ||
|
||
const webpack = require('webpack'); | ||
const webpackConfig = require('./webpack.base.babel.js'); | ||
const path = require('path'); | ||
|
||
// PostCSS plugins | ||
const cssnext = require('postcss-cssnext'); | ||
const postcssFocus = require('postcss-focus'); | ||
const postcssReporter = require('postcss-reporter'); | ||
const cssnano = require('cssnano'); | ||
|
||
module.exports = function getConfig(config) { | ||
module.exports = function(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: ['mocha'], | ||
reporters: ['mocha'], | ||
|
||
browsers: process.env.TRAVIS | ||
? ['ChromeTravis'] | ||
: ['Chrome'], | ||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
'app/**/*.test.js' | ||
], | ||
|
||
autoWatch: process.env.TRAVIS ? false : true, | ||
singleRun: process.env.TRAVIS ? true : false, | ||
|
||
// list of files to exclude | ||
exclude: [ | ||
'node_modules' | ||
files: [ | ||
'../app/**/*.test.js' | ||
], | ||
|
||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
'app/**/*.test.js': ['webpack'] | ||
['../app/**/*.test.js']: ['webpack', 'sourcemap'], | ||
}, | ||
|
||
webpack: webpackConfig({ | ||
context: path.join(__dirname, '..'), | ||
cssLoaders: 'style-loader!css-loader?modules&importLoaders=1!postcss-loader', | ||
postcssPlugins: [ | ||
postcssFocus(), | ||
cssnext({ | ||
browsers: ['last 2 versions', 'IE > 10'] | ||
}), | ||
cssnano({ | ||
autoprefixer: false, // cssnext already runs autoprefixer | ||
discardUnused: false, // unsafe, see http://mxs.is/googmr | ||
zindex: false // unsafe, see http://mxs.is/googmq | ||
}), | ||
postcssReporter({ | ||
clearMessages: true | ||
}) | ||
], | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env': { | ||
NODE_ENV: JSON.stringify('production') | ||
} | ||
}) | ||
] | ||
}), | ||
webpack: webpackConfig, | ||
|
||
// make Webpack bundle generation quiet | ||
webpackMiddleware: { | ||
noInfo: true | ||
}, | ||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['progress'], | ||
|
||
|
||
// 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: ['PhantomJS'], | ||
|
||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: true, | ||
|
||
// Concurrency level | ||
// how many browser should be started simultaneous | ||
concurrency: Infinity, | ||
|
||
plugins: [ | ||
require('karma-webpack'), | ||
require('karma-mocha') | ||
] | ||
customLaunchers: { | ||
ChromeTravis: { | ||
base: 'Chrome', | ||
flags: ['--no-sandbox'] | ||
} | ||
} | ||
}); | ||
}; |