Skip to content

Instantly share code, notes, and snippets.

@gevorg
Last active October 21, 2017 19:58
Show Gist options
  • Save gevorg/3acbeb722ae767fad32fd490f5652e8d to your computer and use it in GitHub Desktop.
Save gevorg/3acbeb722ae767fad32fd490f5652e8d to your computer and use it in GitHub Desktop.
Karma 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', 'chai'],
// Sources.
files: [
'grails-app/assets/javascripts/**/jquery*.js',
'grails-app/assets/javascripts/**/bootstrap*.js',
'grails-app/assets/javascripts/**/*.js',
'src/test/javascript/**test.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: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['mocha', 'junit'],
// web server port
port: 9876,
// 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,
// Report config.
junitReporter: {
outputDir: 'build/test-results/test'
},
// Mocha reporter.
mochaReporter: {
symbols: {
success: '+',
info: '#',
warning: '!',
error: 'x'
}
},
// enable / disable colors in the output (reporters and logs)
colors: true
})
};
// npm install -g karma karma-cli chai karma-chai mocha karma-mocha phantomjs karma-phantomjs-launcher karma-junit-reporter karma-mocha-reporter
//// javascript unit testing
//task testJavaScript(type: Exec) {
// commandLine 'sh', '-c', 'karma start --no-colors'
//}
//
//// include js unit tests into project build lifecycle
//test.dependsOn testJavaScript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment