This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
/
karma.conf.js
230 lines (204 loc) · 7.45 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// Karma configuration
// Generated on Thu Jun 26 2014 17:49:39 GMT-0400 (EDT)
const path = require('path');
const webpack = require('webpack');
module.exports = function (config) {
'use strict';
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine-jquery', 'jasmine', 'sinon'],
// list of files / patterns to load in the browser
files: [
{ pattern: 'node_modules/**/*.js', included: false },
{ pattern: 'node_modules/**/*.underscore', included: false },
// limiting the cldr json files to load (we don't use the other ones and loading too many
// throws errors on a mac)
{ pattern: 'node_modules/cldr-data/supplemental/*.json', included: false },
{ pattern: 'node_modules/cldr-data/availableLocales.json', included: false },
{ pattern: 'node_modules/cldr-data/**/numbers.json', included: false },
{ pattern: 'analytics_dashboard/static/js/load/*.js', included: false },
{ pattern: 'analytics_dashboard/static/js/models/**/*.js', included: false },
{ pattern: 'analytics_dashboard/static/js/views/**/*.js', included: false },
{ pattern: 'analytics_dashboard/static/js/utils/**/*.js', included: false },
{ pattern: 'analytics_dashboard/static/apps/**/*.underscore', included: false },
// actual tests
{ pattern: 'analytics_dashboard/static/js/test/specs/spec-runner.js' },
],
exclude: [
// Don't run library unit tests
'node_modules/**/spec/**/*.js',
'node_modules/**/specs/**/*.js',
'node_modules/**/test/**/*.js',
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'analytics_dashboard/static/js/test/specs/spec-runner.js': ['webpack', 'sourcemap'],
},
// plugins required for running the karma tests
plugins: [
'karma-jasmine',
'karma-jasmine-jquery-2',
'karma-jasmine-html-reporter',
'karma-phantomjs-launcher',
'karma-coverage',
'karma-sinon',
'karma-chrome-launcher',
'karma-webpack',
'karma-sourcemap-loader',
'karma-coverage-istanbul-reporter'
],
webpack: {
// For detailed comments about webpack configuration, see webpack.config.js or webpack.prod.config.js
// This is just slimmed down version of webpack.config.js just for running karma tests
context: __dirname,
resolve: {
modules: [
'node_modules',
'analytics_dashboard/static',
'analytics_dashboard/static/js',
'analytics_dashboard/static/apps',
],
alias: {
marionette: 'backbone.marionette',
cldr: 'cldrjs/dist/cldr',
// Aliases used in tests
uitk: 'edx-ui-toolkit/src/js',
URI: 'urijs/src/URI',
moment: path.resolve('./node_modules/moment'),
jquery: path.resolve('./node_modules/jquery'),
backbone: path.resolve('./node_modules/backbone'),
},
},
output: {
path: path.resolve('./assets/bundles/'),
filename: '[name]-[hash].js',
},
module: {
rules: [
{
test: /\.underscore$/,
use: 'raw-loader',
include: path.join(__dirname, 'analytics_dashboard/static'),
exclude: /node_modules/,
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
use: 'file-loader?name=fonts/[name].[ext]',
include: [
path.join(__dirname, 'analytics_dashboard/static'),
path.join(__dirname, 'node_modules'),
],
},
// The babel-loader transforms newer ES2015 syntax to older ES5 for legacy browsers.
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {
targets: {
browsers: ['last 2 versions', 'ie >= 11'],
},
}],
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
['istanbul', {
exclude: [
'**/*spec.js',
],
}],
],
cacheDirectory: true,
},
},
},
{
test: /\.scss$/,
use: [
{
loader: 'style-loader', // creates style nodes from JS strings
},
{
loader: 'css-loader', // translates CSS into CommonJS
},
{
loader: 'fast-sass-loader', // compiles Sass to CSS. If this breaks, just use sass-loader
},
],
exclude: /node_modules/,
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
include: [
path.join(__dirname, 'analytics_dashboard/static'),
path.join(__dirname, 'node_modules'),
],
},
],
noParse: [/cldr-data|underscore/],
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
// the Insights application loads gettext identity library via django, thus
// components reference gettext globally so a shim is added here to reflect
// the text so tests can be run if modules reference gettext
gettext: 'test/browser-shims/gettext',
ngettext: 'test/browser-shims/ngettext',
}),
// This defines the theme that the SCSS should be building with. For test, this is always open-edx
new webpack.DefinePlugin({
'process.env': {
THEME_SCSS: 'sass/themes/open-edx.scss',
},
}),
],
devtool: 'inline-source-map',
},
webpackMiddleware: {
// silences most webpack log output
noInfo: true,
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage-istanbul'],
coverageIstanbulReporter: {
dir: 'build',
subdir: 'coverage-js',
reporters: [
{ type: 'html', subdir: 'coverage-js/html' },
{ type: 'cobertura', file: 'coverage.xml' },
{ type: 'text-summary' },
],
fixWebpackSourcePaths: true
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN
// || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
// you can also add Chrome or other browsers too
browsers: ['PhantomJS'],
captureTimeout: 60000,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
});
};