forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
125 lines (124 loc) · 4.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
var argv = require('yargs').argv;
var prodEnv = (argv.prod_env === 'True');
var generatedJs = 'third_party/generated/js/third_party.js';
if (prodEnv) {
generatedJs = (
'backend_prod_files/third_party/generated/js/third_party.min.js');
}
module.exports = function(config) {
config.set({
basePath: '../../',
// jasmine-jquery is used to load contents of external JSON files in tests.
frameworks: ['jasmine-jquery', 'jasmine'],
files: [
'core/tests/karma-globals.js',
// Constants must be loaded before everything else.
'assets/constants.js',
'assets/rich_text_components_definitions.js',
// Since jquery,jquery-ui,angular,angular-mocks and math-expressions
// are not bundled, they will be treated separately.
'third_party/static/jquery-3.2.1/jquery.min.js',
'third_party/static/jqueryui-1.12.1/jquery-ui.min.js',
'third_party/static/angularjs-1.5.8/angular.js',
'third_party/static/angularjs-1.5.8/angular-mocks.js',
'third_party/static/headroom-js-0.9.4/headroom.min.js',
'third_party/static/headroom-js-0.9.4/angular.headroom.min.js',
'third_party/static/math-expressions-370a77/build/math-expressions.js',
generatedJs,
'core/templates/dev/head/*.js',
// Note that unexpected errors occur ("Cannot read property 'num' of
// undefined" in MusicNotesInput.js) if the order of core/templates/...
// and extensions/... are switched. The test framework may be flaky.
'core/templates/dev/head/**/*.js',
'core/templates/dev/head/**/*_directive.html',
'extensions/**/*.js',
{
pattern: 'extensions/**/*.png',
watched: false,
served: true,
included: false
},
'extensions/interactions/**/*_directive.html',
'extensions/interactions/rule_templates.json',
{
pattern: 'assets/i18n/**/*.json',
watched: true,
served: true,
included: false
},
{
pattern: 'core/tests/data/**/*.json',
watched: false,
served: true,
included: false
}
],
exclude: [
'core/templates/dev/head/**/*-e2e.js',
'extensions/**/protractor.js',
'backend_prod_files/extensions/**'
],
proxies: {
// Karma serves files under the /base directory.
// We access files directly in our code, for example /folder/,
// so we need to proxy the requests from /folder/ to /base/folder/.
'/assets/': '/base/assets/',
'/extensions/': '/base/extensions/'
},
preprocessors: {
'core/templates/dev/head/!(*Spec).js': ['coverage'],
'core/templates/dev/head/**/!(*Spec).js': ['coverage'],
'extensions/!(*Spec).js': ['coverage'],
'extensions/**/!(*Spec).js': ['coverage'],
// Note that these files should contain only directive templates, and no
// Jinja expressions. They should also be specified within the 'files'
// list above.
'core/templates/dev/head/**/*_directive.html': ['ng-html2js'],
'extensions/interactions/**/*_directive.html': ['ng-html2js'],
'extensions/interactions/rule_templates.json': ['json_fixtures']
},
reporters: ['progress', 'coverage'],
coverageReporter: {
reporters: [{
type: 'html'
}, {
type: 'json'
}],
subdir: '.',
dir: '../karma_coverage_reports/'
},
autoWatch: true,
browsers: ['Chrome_Travis'],
// Kill the browser if it does not capture in the given timeout [ms].
captureTimeout: 60000,
browserConsoleLogOptions: {
level: 'log',
format: '%b %T: %m',
terminal: true
},
browserNoActivityTimeout: 60000,
// Continue running in the background after running tests.
singleRun: true,
customLaunchers: {
Chrome_Travis: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
plugins: [
'karma-jasmine-jquery',
'karma-jasmine',
'karma-chrome-launcher',
'karma-ng-html2js-preprocessor',
'karma-json-fixtures-preprocessor',
'karma-coverage'
],
ngHtml2JsPreprocessor: {
moduleName: 'directiveTemplates',
prependPrefix: '/'
},
jsonFixturesPreprocessor: {
variableName: '__fixtures__'
}
});
};