Skip to content

Instantly share code, notes, and snippets.

@RB-Lab
Created November 30, 2015 10:39
Show Gist options
  • Save RB-Lab/3bc44ccc6687095962b6 to your computer and use it in GitHub Desktop.
Save RB-Lab/3bc44ccc6687095962b6 to your computer and use it in GitHub Desktop.
Minimal Karma config for use with React & Babel & Browserify
// you need to $ npm i -D babel-preset-es2015 babel-preset-react babel-preset-stage-0 babelify karma karma-browserify karma-chai karma-mocha karma-mocha-reporter karma-phantomjs-launcher phantomjs-polyfill array.from
module.exports = function conf(config) {
config.set({
frameworks: ['browserify', 'mocha', 'chai'],
plugins: [
'karma-browserify',
'karma-mocha',
'karma-chai',
'karma-phantomjs-launcher',
'karma-mocha-reporter'
],
files: [
'./node_modules/phantomjs-polyfill/bind-polyfill.js',
'./node_modules/array.from/array-from.js',
'src/*.js',
'src/__tests__/*-test.js'
],
preprocessors: {
'src/**/*.js': ['browserify']
},
browserify: {
configure: function browserify(bundle) {
bundle.once('prebundle', function prebundle() {
bundle.transform('babelify', {presets: ['es2015', 'react', 'stage-0']});
});
}
},
reporters: ['mocha'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false,
concurrency: Infinity
});
};
@RB-Lab
Copy link
Author

RB-Lab commented Jun 10, 2016

for webpack deps would be:

$ npm i -D karma mocha chai phantomjs-prebuilt karma-chai karma-mocha karma-mocha-reporter karma-phantomjs-launcher phantomjs-polyfill array.from karma-webpack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment