-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
129 lines (116 loc) · 3.2 KB
/
karma.conf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// karma start
// OR
// karma start -D
// for debugging tests: it launches Chrome.
// Then click on the DEBUG button, and in the new tab, open the DevTools. Go to Sources, put breakpoints, refresh.
// In debug mode, we listen for file changes and re-run the tests.
// Can also add the -V flag to get a verbose output: list each test description, and output a Json summary.
/* eslint-env node */
'use strict';
function isDebug(argument)
{
return argument === '-D';
}
function isVerbose(argument)
{
return argument === '-V';
}
var debug = process.argv.some(isDebug);
var verbose = process.argv.some(isVerbose);
// Reference: http://karma-runner.github.io/0.12/config/configuration-file.html
module.exports = function karmaConfig(config)
{
var plugins =
[
'karma-webpack', 'karma-sourcemap-loader',
'karma-jasmine',
'karma-chrome-launcher', 'karma-firefox-launcher',
];
if (verbose)
{
plugins.push('karma-spec-reporter'); // Show each test name as it is run; useful to pin-point a crash
plugins.push('karma-jsonsummary-reporter'); // Can be useful too... :-)
}
if (!debug)
{
plugins.push('karma-phantomjs-launcher');
plugins.push('karma-growl-reporter'); // Show notifications in the tray
plugins.push('karma-coverage');
}
var reporters = [ 'dots' ];
if (verbose)
{
// Reference: https://github.com/mlex/karma-spec-reporter
// Set reporter to print detailed results to console.
reporters = [ 'spec', 'jsonsummary' ];
}
if (!debug)
{
// Reference: https://github.com/karma-runner/karma-coverage
// Output code coverage files.
reporters.push('coverage');
reporters.push('growl');
}
var configuration =
{
frameworks:
[
// Reference: https://github.com/karma-runner/karma-jasmine
// Set framework to Jasmine
'jasmine'
],
plugins: plugins,
reporters: reporters,
files:
[
'src/tests.webpack.js'
],
exclude: [],
preprocessors:
{
// Reference: http://webpack.github.io/docs/testing.html
// Reference: https://github.com/webpack/karma-webpack
// Convert files with Webpack and load sourcemaps.
'src/tests.webpack.js': [ 'webpack', 'sourcemap' ]
},
// Run tests using Chrome (for debugging) or PhantomJS
browsers: debug ? [ 'Chrome' ] : [ 'PhantomJS' ],
autoWatch: debug,
singleRun: !debug,
// Configure code coverage reporter
coverageReporter:
{
dir: 'coverage/',
subdir: function (browser)
{
return browser.toLowerCase().split(/[ /-]/)[0];
},
reporters:
[
{ type: 'text-summary' },
{ type: 'html' }
]
},
specReporter:
{
maxLogLines: 5, // limit number of lines logged per test
suppressErrorSummary: false, // do not print error summary
suppressFailed: false, // do not print information about failed tests
suppressPassed: false, // do not print information about passed tests
suppressSkipped: true, // do not print information about skipped tests
showSpecTiming: false // print the time elapsed for each spec
},
jsonReporter:
{
stdout: true,
// outputFile: 'results.json', // defaults to none
},
webpack: require('./webpack.config'),
// Hide Webpack build information from output
webpackMiddleware:
{
noInfo: 'errors-only'
}
};
config.set(configuration);
};