1- var path = require ( 'path' ) ;
2-
3- var webpackConfig = require ( './webpack.config' ) ;
4-
5- var ENV = process . env . npm_lifecycle_event ;
6- var isTestWatch = ENV === 'test-watch' ;
1+ // Karma configuration file, see link for more information
2+ // https://karma-runner.github.io/0.13/config/configuration-file.html
73
84module . exports = function ( config ) {
9- var _config = {
10-
11- // base path that will be used to resolve all patterns (eg. files, exclude)
5+ config . set ( {
126 basePath : '' ,
13-
14- // frameworks to use
15- // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
16- frameworks : [ 'jasmine' ] ,
17-
18- // list of files / patterns to load in the browser
19- files : [
20- { pattern : './karma-shim.js' , watched : false }
7+ frameworks : [ 'jasmine' , '@angular/cli' ] ,
8+ plugins : [
9+ require ( 'karma-jasmine' ) ,
10+ require ( 'karma-chrome-launcher' ) ,
11+ require ( 'karma-junit-reporter' ) ,
12+ require ( 'karma-mocha-reporter' ) ,
13+ require ( 'karma-jasmine-html-reporter' ) ,
14+ require ( 'karma-coverage-istanbul-reporter' ) ,
15+ require ( '@angular/cli/plugins/karma' )
2116 ] ,
22-
23- // list of files to exclude
24- exclude : [ ] ,
25-
26- // preprocess matching files before serving them to the browser
27- // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
28- preprocessors : {
29- './karma-shim.js' : [ 'webpack' , 'sourcemap' ]
17+ client : {
18+ clearContext : false // leave Jasmine Spec Runner output visible in browser
3019 } ,
31-
32- webpack : webpackConfig ,
33-
34- webpackMiddleware : {
35- // webpack-dev-middleware configuration
36- // i. e.
37- stats : 'errors-only'
20+ coverageIstanbulReporter : {
21+ dir : 'reports/coverage' ,
22+ 'report-config' : {
23+ cobertura : {
24+ file : 'cobertura/cobertura.xml'
25+ }
26+ } ,
27+ reports : [ 'html' , 'lcovonly' , 'cobertura' ] ,
28+ fixWebpackSourcePaths : true
3829 } ,
39-
40- webpackServer : {
41- noInfo : true // please don't spam the console when running in karma!
30+ angularCli : {
31+ environment : 'dev'
4232 } ,
43-
44- // test results reporter to use
45- // possible values: 'dots', 'progress', 'mocha'
46- // available reporters: https://npmjs.org/browse/keyword/karma-reporter
47- reporters : [ 'mocha' ] ,
48-
49- // web server port
33+ reporters : [ 'mocha' , 'junit' , 'kjhtml' , 'coverage-istanbul' ] ,
5034 port : 9876 ,
51-
52- // enable / disable colors in the output (reporters and logs)
35+ junitReporter : {
36+ outputDir : 'reports' , // results will be saved as $outputDir/$browserName.xml
37+ outputFile : 'junit.xml' , // if included, results will be saved as $outputDir/$browserName/$outputFile
38+ suite : '' , // suite will become the package name attribute in xml testsuite element
39+ useBrowserName : false // add browser name to report and classes names
40+ } ,
5341 colors : true ,
54-
55- // level of logging
56- // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
5742 logLevel : config . LOG_INFO ,
58-
59- // enable / disable watching file and executing tests whenever any file changes
60- autoWatch : false ,
61-
62- // start these browsers
63- // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
64- browsers : isTestWatch ? [ 'Chrome' ] : [ 'ChromeHeadless' ] ,
65-
43+ autoWatch : true ,
44+ browsers : [ 'ChromeHeadless' ] ,
6645 customLaunchers : {
6746 ChromeHeadless : {
6847 base : 'Chrome' ,
@@ -74,40 +53,6 @@ module.exports = function (config) {
7453 ]
7554 }
7655 } ,
77-
78- // Continuous Integration mode
79- // if true, Karma captures browsers, runs the tests and exits
80- singleRun : true
81- } ;
82-
83- if ( ! isTestWatch ) {
84- _config . reporters . push ( 'coverage' ) ;
85- _config . reporters . push ( 'junit' ) ;
86-
87- _config . junitReporter = {
88- outputDir : 'reports' , // results will be saved as $outputDir/$browserName.xml
89- outputFile : 'junit.xml' , // if included, results will be saved as $outputDir/$browserName/$outputFile
90- suite : '' , // suite will become the package name attribute in xml testsuite element
91- useBrowserName : false // add browser name to report and classes names
92- } ;
93-
94- _config . coverageReporter = {
95- dir : 'reports/' ,
96- reporters : [
97- {
98- type : 'json' ,
99- subdir : 'coverage/json' ,
100- file : 'coverage-final.json'
101- } ,
102- {
103- type : 'cobertura' ,
104- subdir : 'coverage/cobertura' ,
105- file : 'cobertura.xml'
106- }
107- ]
108- } ;
109- }
110-
111- config . set ( _config ) ;
112-
56+ singleRun : false
57+ } ) ;
11358} ;
0 commit comments