Created
July 25, 2018 07:04
-
-
Save workfel/8b3508f0b367ef17d0408311510e696a to your computer and use it in GitHub Desktop.
Angular Karma configuration for VSTS with junit & cobertura coverage config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Karma configuration file, see link for more information | |
// https://karma-runner.github.io/0.13/config/configuration-file.html | |
process.env.CHROME_BIN = require('puppeteer').executablePath(); | |
module.exports = function (config) { | |
config.set({ | |
basePath: '', | |
frameworks: ['jasmine', '@angular/cli'], | |
plugins: [ | |
require('karma-jasmine'), | |
require('karma-chrome-launcher'), | |
require('karma-jasmine-html-reporter'), | |
require('karma-coverage-istanbul-reporter'), | |
require('@angular/cli/plugins/karma'), | |
require('karma-junit-reporter'), | |
require('karma-spec-reporter') | |
], | |
customLaunchers: { | |
ChromeHeadless: { | |
base: 'Chrome', | |
flags: [ | |
// See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md | |
'--headless', | |
'--disable-gpu', | |
// Without a remote debugging port, Google Chrome exits immediately. | |
'--remote-debugging-port=9222', | |
'--disable-translate', | |
'--disable-extensions' | |
], | |
} | |
}, | |
client: { | |
clearContext: false // leave Jasmine Spec Runner output visible in browser | |
}, | |
files: [ | |
{pattern: './src/test.ts', watched: false}, | |
{pattern: './node_modules/hammerjs/hammer.min.js'}, | |
{pattern: './node_modules/@angular/material/prebuilt-themes/indigo-pink.css', included: true, watched: true}, | |
], | |
preprocessors: { | |
'./src/test.ts': ['@angular/cli'] | |
}, | |
mime: { | |
'text/x-typescript': ['ts', 'tsx'] | |
}, | |
remapIstanbulReporter: { | |
reports: { | |
html: 'coverage', | |
lcovonly: './coverage/coverage.lcov' | |
} | |
}, | |
specReporter: { | |
maxLogLines: 5, | |
suppressErrorSummary: false, // do not print error summary | |
suppressFailed: false, // print info about failed tests | |
suppressPassed: false, // print info about passed tests | |
suppressSkipped: true, // do not print info about skipped tests | |
showSpecTiming: true, // print time elapsed for each spec | |
failFast: false // keep running tests after first error found | |
}, | |
coverageIstanbulReporter: { | |
reports: ['html', 'lcovonly', 'text-summary', 'cobertura'], | |
fixWebPackSourcePaths: true | |
}, | |
angularCli: { | |
environment: 'dev' | |
}, | |
reporters: config.angularCli && config.angularCli.codeCoverage | |
? ['spec', 'coverage-istanbul', 'junit'] | |
: ['progress', 'kjhtml', 'junit'], | |
port: 9876, | |
colors: true, | |
logLevel: config.LOG_INFO, | |
autoWatch: false, | |
browsers: ['ChromeHeadless'], | |
singleRun: true, | |
junitReporter: { | |
outputDir: 'test', | |
outputFile: 'test.xml' | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment