Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
application karma config
var _ = require('lodash');
var appConfig = require('./app-config.json');
// Check for custom app configuration, override if necessary
try {
var customConfig = require('./app-config-custom.json');
_.merge(customConfig, appConfig, _.defaults);
appConfig = customConfig;
} catch (e) {
// swallow
}
module.exports = function(config) {
// Load JSKit RequireJS configuration
require('./tmp/lib/jskit/config.js');
var jskitRequireConfig = requirejs.config();
// Load App RequireJS configuration
require(SRC_DIR + '/config.js');
var appRequireConfig = requirejs.config();
var karmaConf = {
// 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', 'requirejs', 'chai', 'sinon-chai', 'chai-as-promised','es6-shim'],
// list of files / patterns to load in the browser
files: [
'test-main.js', {
pattern: SRCTEST_DIR + '/**',
included: false
}, {
pattern: BUILDTEST_DIR + '/**',
included: false
}
],
// 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: { /*set below */ },
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage', 'junit'],
junitReporter: {
outputFile: 'test-results.xml',
suite: '[JS] ' + appConfig.testSuite + ' - '
},
// optionally, configure the reporter
coverageReporter: {
reportBasePath: appConfig.coverageBasePath || '.',
type: 'lcov',
dir: 'coverage/',
subdir: '.'
},
// 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: true,
//Polling bypass the filesystem's change event and instead use polling within Karma; more memory use,
// but better at detecting changes
usePolling: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
//browsers: ['Chrome', 'Firefox', 'PhantomJS'],
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
client: {
jskitRequireConfig: jskitRequireConfig,
appRequireConfig: appRequireConfig,
captureConsole: true,
useIframe: true
}
};
karmaConf.preprocessors[BUILDTEST_DIR + '/*.js'] = ['coverage'];
karmaConf.preprocessors[BUILDTEST_DIR + '/!(lib)/**/*.js'] = ['coverage'];
config.set(karmaConf);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.