Skip to content

Instantly share code, notes, and snippets.

@gupta-abhay
Created January 12, 2017 16:29
Show Gist options
  • Save gupta-abhay/21188e548b7f11731273070a78560f5a to your computer and use it in GitHub Desktop.
Save gupta-abhay/21188e548b7f11731273070a78560f5a to your computer and use it in GitHub Desktop.
Karma Configuration to run on VSO Hosted Agents
// 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: ['jasmine'],
// list of files / patterns to load in the browser
files: [
// Libraries
'Scripts/angular.js'
, 'UnitTests/Lib/angular-mocks.js'
, 'UnitTests/Lib/jasmine.js'
, 'Scripts/test-script.js'
// Common
, 'Common/test-common.js'
// Config
, 'App/config.js'
, 'App/app.js'
// Services
, 'App/Services/test-service.js'
// Helpers
, 'App/Helpers/test-helper.js'
// Models
, 'App/Models/test-models.js'
// Controllers
, 'App/Controllers/test-file-name.js'
// Directives
, 'App/Directive/test-directive.js'
// Test Controllers
, 'UnitTests/App/Controllers/test-file-name-test.js'
// Test Data
, 'UnitTests/TestData/testdata-sample.js'
],
// list of files to exclude
exclude: [
'App/Services/test-file-name-1.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
// add files for which coverage is desired
preprocessors: {
'App/Controllers/test-file-name.js': ['coverage']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage', 'html', 'junit'],
coverageReporter: {
// specify a common output directory
dir: 'coverage',
reporters: [
{
type: 'html', subdir: 'report-html'
},
{
type: 'lcov', subdir: 'report-lcov'
},
{
type: 'cobertura', subdir: '.', file: 'cobertura.xml'
},
{
type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt'
},
{
type: 'teamcity', subdir: '.', file: 'teamcity.txt'
},
{
type: 'text', subdir: '.', file: 'text.txt'
},
{
type: 'text-summary', subdir: '.', file: 'text-summary.txt'
},
]
},
htmlReporter: {
outputDir: 'karma_html', // where to put the reports
templatePath: null, // set if you moved jasmine_template.html
focusOnFailures: true, // reports show failures on start
namedFiles: false, // name files instead of creating sub-directories
pageTitle: null, // page title for reports; browser info by default
urlFriendlyName: false, // simply replaces spaces with _ for files/dirs
reportName: 'report-summary-filename', // report summary filename; browser info by default
// experimental
preserveDescribeNesting: false, // folded suites stay folded
foldAll: false, // reports start folded (only with preserveDescribeNesting)
},
junitReporter: {
outputFile: 'Test/out/unit.xml',
suite: 'unit'
},
// web server port
port: 9876,
// host
hostname: '127.0.0.1',
// urlRoot
urlRoot: '/',
// 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,
// 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
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment