Skip to content

Instantly share code, notes, and snippets.

@joetm
Created January 23, 2016 10:39
Show Gist options
  • Save joetm/32f2ae7d00086012a07d to your computer and use it in GitHub Desktop.
Save joetm/32f2ae7d00086012a07d to your computer and use it in GitHub Desktop.
// Karma configuration
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: './',
//browserNoActivityTimeout: 100000,
//captureTimeout: 90000,
client: {
useIframe: false, //for best compatibility
captureConsole: false //silencio!
},
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: [
'jasmine-jquery',
'jasmine',
'requirejs' //to load requirejs modules
//'fixture' //to load html and json - see https://www.npmjs.com/package/karma-fixture
],
// list of files / patterns
files: [
//frontend
{pattern: 'frontend/js/vendor/**/*.js', served: true, included: false},
{pattern: 'frontend/js/*.js', watched: true, served: true, included: false},
{pattern: 'frontend/templates/*.*', watched: true, served: true, included: false},
{pattern: 'frontend/data/*.*', watched: true, served: true, included: false},
{pattern: 'frontend/css/**/*.css', served: true, included: false},
{pattern: 'frontend/css/**/*.js', served: true, included: false},
{pattern: 'frontend/css/**/*.woff', served: true, included: false},
{pattern: 'frontend/css/**/*.ttf', served: true, included: false},
{pattern: 'frontend/css/**/*.woff2', served: true, included: false},
{pattern: 'frontend/css/**/*.svg', served: true, included: false},
{pattern: 'frontend/css/**/*.eot', served: true, included: false},
{pattern: 'frontend/font/*.*', served: true, included: false},
{pattern: 'frontend/img/*.*', served: true, included: false},
//test-specific
{pattern: 'test/**/*Spec.js', watched: true, included: false},
//jasmine helpers
//'test/helpers/jasmine-jquery.js',
'test/helpers/jasmine-ajax-helper.js',
'test/test-main.js'
],
// list of files to exclude
exclude: [
//frontend
"frontend/js/vendor/**/test/*.js", //do not include the vendor tests
"frontend/js/vendor/**/node_modules/*.js", //do not include the vendor modules
"test/node/**/*.js" //node tests
],
proxies: {
"/templates/": "/base/frontend/templates/",
"/base/../templates/": "/base/frontend/templates/",
"/data/": "/base/frontend/data/",
"/base/../data/": "/base/frontend/data/",
"/css/": "/base/frontend/css/",
"/base/frontend/css/frontend/css/": "/base/frontend/css/",
"/img/": "/base/frontend/img/",
"/js/vendor/": "/base/frontend/js/vendor/",
"/js/frontend/js/": "/base/frontend/js/",
"/js/": "/base/frontend/js/",
"/base/frontend/js/frontend/css/": "/base/frontend/css/"
},
/*
plugins: [
'karma-firefox-launcher',
//'karma-chrome-launcher',
//'karma-opera-launcher',
//'karma-ie-launcher',
'karma-jasmine'
],
*/
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
// preprocessors to load html and json files - see https://www.npmjs.com/package/karma-fixture#installation
preprocessors: {
'frontend/js/*.js': ['coverage']
//'node/**/*.js' : ['coverage'],
//'**/*.html' : ['html2js']
//'**/*.json' : ['json_fixtures']
},
//jsonFixturesPreprocessor: {
// variableName: '__json__'
//},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: [
'progress',
'coverage'
],
//see https://github.com/karma-runner/karma-coverage
coverageReporter: {
type : 'lcov',
dir : 'test/coverage/',
//subdir: '.' //output the results into: 'test/coverage/'
subdir: function (browser) {
return browser.toLowerCase().split(/[ /-]/)[0];
}
},
// 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_WARN,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
//browsers: ['PhantomJS'], //'Chrome' is not compatible with travis-ci
browsers: [
'Firefox'
],
//'Chrome' //travis-ci does not accept Chrome browser
//'PhantomJS', 'PhantomJS_custom'
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
/*PhantomJS config*/
/*
customLaunchers: {
'PhantomJS_custom': {
base: 'PhantomJS',
options: {
windowName: 'my-window',
settings: {
webSecurityEnabled: false
},
},
flags: ['--load-images=true'],
debug: true
}
},
phantomjsLauncher: {
// Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
exitOnResourceError: true
}
*/
});//config.set
};//module.exports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment