-
Notifications
You must be signed in to change notification settings - Fork 667
/
_karma.conf.js
113 lines (93 loc) · 3.21 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
'use strict';
var path = require('path');
var conf = require('./gulp/conf');
var _ = require('lodash');
var wiredep = require('wiredep');
function listFiles() {
var wiredepOptions = _.extend({}, conf.wiredep, {
dependencies: true,
devDependencies: true
});
return wiredep(wiredepOptions).js
.concat([
<% if (props.jsPreprocessor.key === 'noJsPrepro') { -%>
path.join(conf.paths.src, '/app/**/*.module.js'),
path.join(conf.paths.src, '/app/**/*.js'),
path.join(conf.paths.src, '/**/*.spec.js'),
path.join(conf.paths.src, '/**/*.mock.js'),
<% } else if (props.jsPreprocessor.key === 'coffee') { -%>
path.join(conf.paths.tmp, '/serve/app/**/*.module.js'),
path.join(conf.paths.tmp, '/serve/app/**/*.js'),
path.join(conf.paths.tmp, '/**/*.spec.js'),
path.join(conf.paths.tmp, '/**/*.mock.js'),
<% } else { -%>
path.join(conf.paths.tmp, '/serve/app/index.module.js'),
<% } -%>
path.join(conf.paths.src, '/**/*.html')
]);
}
module.exports = function(config) {
var configuration = {
files: listFiles(),
singleRun: true,
autoWatch: false,
ngHtml2JsPreprocessor: {
stripPrefix: conf.paths.src + '/',
moduleName: '<%- appName %>'
},
logLevel: 'WARN',
<% if (props.jsPreprocessor.key === 'noJsPrepro' || props.jsPreprocessor.key === 'coffee') { -%>
frameworks: ['jasmine', 'angular-filesort'],
angularFilesort: {
<% if (props.jsPreprocessor.key === 'noJsPrepro') { -%>
whitelist: [path.join(conf.paths.src, '/**/!(*.html|*.spec|*.mock).js')]
<% } else { -%>
whitelist: [path.join(conf.paths.tmp, '/**/!(*.html|*.spec|*.mock).js')]
<% } -%>
},
<% } else { -%>
frameworks: ['jasmine'],
<% } -%>
<% if(props.jsPreprocessor.key === 'traceur') { -%>
browsers : ['Chrome'],
plugins : [
'karma-chrome-launcher',
<% } else { -%>
browsers : ['PhantomJS'],
plugins : [
'karma-phantomjs-launcher',
<% } if (props.jsPreprocessor.key === 'noJsPrepro' || props.jsPreprocessor.key === 'coffee') { -%>
'karma-angular-filesort',
<% } -%>
'karma-coverage',
'karma-jasmine',
'karma-ng-html2js-preprocessor'
],
coverageReporter: {
type : 'html',
dir : 'coverage/'
},
reporters: ['progress']
};
// This is the default preprocessors configuration for a usage with Karma cli
// The coverage preprocessor in added in gulp/unit-test.js only for single tests
// It was not possible to do it there because karma doesn't let us now if we are
// running a single test or not
var pathSrcHtml = path.join(conf.paths.src, '/**/*.html');
configuration.preprocessors = {};
configuration.preprocessors[pathSrcHtml] = ['ng-html2js'];
// This block is needed to execute Chrome on Travis
// If you ever plan to use Chrome and Travis, you can keep it
// If not, you can safely remove it
// https://github.com/karma-runner/karma/issues/1144#issuecomment-53633076
if(configuration.browsers[0] === 'Chrome' && process.env.TRAVIS) {
configuration.customLaunchers = {
'chrome-travis-ci': {
base: 'Chrome',
flags: ['--no-sandbox']
}
};
configuration.browsers = ['chrome-travis-ci'];
}
config.set(configuration);
};