Skip to content

Commit

Permalink
Move Karma config to webpack folder, make karma test single run
Browse files Browse the repository at this point in the history
  • Loading branch information
mxstbr committed Jan 25, 2016
1 parent abb597a commit 0728be1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 136 deletions.
38 changes: 0 additions & 38 deletions karma.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"lint": "eslint .",
"lint:staged": "eslint-staged",
"pretest": "npm run lint",
"test": "NODE_ENV=test karma start karma.config.js",
"test": "NODE_ENV=test karma start webpack/karma.conf.js --single-run",
"test:mocha": "NODE_ENV=test mocha --compilers js:babel-core/register,css:css-modules-require-hook --require ./webpack/testHelper.js --recursive 'app/**/*.test.js'",
"test:mocha:watch": "NODE_ENV=test npm test -- --watch",
"start": "NODE_ENV=development node webpack/server.dev.js",
Expand Down
118 changes: 21 additions & 97 deletions webpack/karma.conf.js
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']
}
}
});
};

0 comments on commit 0728be1

Please sign in to comment.