Skip to content

Instantly share code, notes, and snippets.

@grndrth
Created October 12, 2015 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grndrth/e739883687b14f8b060b to your computer and use it in GitHub Desktop.
Save grndrth/e739883687b14f8b060b to your computer and use it in GitHub Desktop.
Setting up Karma with Mocha, Chai, Babel, CommonJS. Everything else in karma.conf.js can be left at standard settings.
// Karma configuration
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: ['chai', 'mocha', 'commonjs'],
// list of files / patterns to load in the browser
files: [
'path/to/code/**/*.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'path/to/code/**/*.js': ['babel', 'sourcemap', 'commonjs']
},
babelPreprocessor: {
options: {
sourceMap: 'inline'
}
},
// [....]
plugins: [
"karma-mocha",
"karma-chai",
"karma-commonjs",
"karma-babel-preprocessor",
"karma-sourcemap-loader"
],
// [....]
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment